孙民选个人论坛

鏍囬: phpcms鍔犺浇pc_base::load_config [鎵撳嵃鏈〉]

浣滆: admin    鏃堕棿: 2017-11-7 04:17
鏍囬: phpcms鍔犺浇pc_base::load_config
鍔犺浇閰嶇疆鏂囦欢
  1. $setconfig = pc_base::load_config('system');        
澶嶅埗浠g爜


琛ㄧず鍔犺浇caches/configs 閲岄潰鐨剆ystem.php涔熷彲浠ュ彇鍗曚釜鍊
  1. //瀹氫箟缃戠珯鏍硅矾寰
  2. define('WEB_PATH',pc_base::load_config('system','web_path'));
  3. //js 璺緞
  4. define('JS_PATH',pc_base::load_config('system','js_path'));
  5. //css 璺緞
  6. define('CSS_PATH',pc_base::load_config('system','css_path'));
  7. //img 璺緞
  8. define('IMG_PATH',pc_base::load_config('system','img_path'));
  9. //鍔ㄦ佺▼搴忚矾寰
  10. define('APP_PATH',pc_base::load_config('system','app_path'));
澶嶅埗浠g爜


婧愮爜
  1. /**
  2.          * 鍔犺浇閰嶇疆鏂囦欢
  3.          * @param string $file 閰嶇疆鏂囦欢
  4.          * @param string $key  瑕佽幏鍙栫殑閰嶇疆鑽
  5.          * @param string $default  榛樿閰嶇疆銆傚綋鑾峰彇閰嶇疆椤圭洰澶辫触鏃惰鍊煎彂鐢熶綔鐢ㄣ
  6.          * @param boolean $reload 寮哄埗閲嶆柊鍔犺浇銆
  7.          */
  8.         public static function load_config($file, $key = '', $default = '', $reload = false) {
  9.                 static $configs = array();
  10.                 if (!$reload && isset($configs[$file])) {
  11.                         if (empty($key)) {
  12.                                 return $configs[$file];
  13.                         } elseif (isset($configs[$file][$key])) {
  14.                                 return $configs[$file][$key];
  15.                         } else {
  16.                                 return $default;
  17.                         }
  18.                 }
  19.                 $path = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.$file.'.php';
  20.                 if (file_exists($path)) {
  21.                         $configs[$file] = include $path;
  22.                 }
  23.                 if (empty($key)) {
  24.                         return $configs[$file];
  25.                 } elseif (isset($configs[$file][$key])) {
  26.                         return $configs[$file][$key];
  27.                 } else {
  28.                         return $default;
  29.                 }
  30.         }
澶嶅埗浠g爜









娆㈣繋鍏変复 孙民选个人论坛 (http://www.sunminxuan.cn/bbs/) Powered by Discuz! X3.4