當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Basic::setConstant方法代碼示例

本文整理匯總了PHP中Basic::setConstant方法的典型用法代碼示例。如果您正苦於以下問題:PHP Basic::setConstant方法的具體用法?PHP Basic::setConstant怎麽用?PHP Basic::setConstant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Basic的用法示例。


在下文中一共展示了Basic::setConstant方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parsIni

 /**
     Parses the configuration file.
     @param string $filename Path to the configuration file.
     @return null.
     **/
 public static function parsIni($filename)
 {
     if (empty($filename) || !file_exists($filename)) {
         return "Configuration not found";
     }
     $config = parse_ini_file($filename, true);
     Basic::setConstant("DEFAULT_SOCKET_TIMEOUT", Basic::getConfigKey($config, 'general', 'socketTimeout'), 10);
     $phpCommand = Basic::getConfigKey($config, 'general', 'phpCommand');
     if (!empty($phpCommand)) {
         static::$phpCommand = $phpCommand;
     }
     $disablePanelTitle = Basic::getConfigKey($config, 'general', 'disablePanelTitle');
     if (!empty($disablePanelTitle)) {
         static::$disablePanelTitle = $disablePanelTitle;
     }
     Basic::setConstant("TMP_FOLDER", Basic::getConfigKey($config, 'general', 'tmpFolder'), sys_get_temp_dir());
     Basic::setConstant("SPECIAL_CHAR", Basic::getConfigKey($config, 'general', 'specialChar'), "&");
     Basic::setConstant("DATABASE_TYPE", strtolower(Basic::getConfigKey($config, 'general', 'databaseType')), "influxdb");
     Basic::setConstant("FORECAST_DATASOURCE_NAME", strtolower(Basic::getConfigKey($config, 'general', 'forecastDatasourceName')), "nagflux_forecast");
     Basic::setConstant("URL", Basic::getConfigKey($config, DATABASE_TYPE, 'url'), "http://127.0.0.1:8086/query?db=nagflux");
     define('INFLUXDB', 'influxdb');
     define('ELASTICSEARCH', 'elasticsearch');
     if (DATABASE_TYPE == INFLUXDB && preg_match(";db=(\\w*);", URL, $matches)) {
         define('INFLUXDB_DB', $matches[1]);
     } elseif (DATABASE_TYPE == ELASTICSEARCH) {
         $path = parse_url(URL, PHP_URL_PATH);
         if ($path) {
             define('ELASTICSEARCH_INDEX', ltrim($path, '/'));
         }
     }
     Basic::setConstant("HOSTCHECK_ALIAS", Basic::getConfigKey($config, DATABASE_TYPE, 'hostcheckAlias'), "hostcheck");
     Basic::setConstant("DEFAULT_TEMPLATE_FOLDER", Basic::getConfigKey($config, 'folder', 'defaultTemplateFolder'), "histou/templates/default/");
     Basic::setConstant("CUSTOM_TEMPLATE_FOLDER", Basic::getConfigKey($config, 'folder', 'customTemplateFolder'), "histou/templates/custom/");
     Basic::setConstant("FORECAST_TEMPLATE_FOLDER", Basic::getConfigKey($config, 'folder', 'forecastTemplateFolder'), "histou/forecasts/");
 }
開發者ID:Griesbacher,項目名稱:histou,代碼行數:40,代碼來源:basic.php


注:本文中的Basic::setConstant方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。