孙民选个人论坛
鏍囬:
phpcms鍔犺浇pc_base::load_config
[鎵撳嵃鏈〉]
浣滆:
admin
鏃堕棿:
2017-11-7 04:17
鏍囬:
phpcms鍔犺浇pc_base::load_config
鍔犺浇閰嶇疆鏂囦欢
$setconfig = pc_base::load_config('system');
澶嶅埗浠g爜
琛ㄧず鍔犺浇caches/configs 閲岄潰鐨剆ystem.php涔熷彲浠ュ彇鍗曚釜鍊
//瀹氫箟缃戠珯鏍硅矾寰
define('WEB_PATH',pc_base::load_config('system','web_path'));
//js 璺緞
define('JS_PATH',pc_base::load_config('system','js_path'));
//css 璺緞
define('CSS_PATH',pc_base::load_config('system','css_path'));
//img 璺緞
define('IMG_PATH',pc_base::load_config('system','img_path'));
//鍔ㄦ佺▼搴忚矾寰
define('APP_PATH',pc_base::load_config('system','app_path'));
澶嶅埗浠g爜
婧愮爜
/**
* 鍔犺浇閰嶇疆鏂囦欢
* @param string $file 閰嶇疆鏂囦欢
* @param string $key 瑕佽幏鍙栫殑閰嶇疆鑽
* @param string $default 榛樿閰嶇疆銆傚綋鑾峰彇閰嶇疆椤圭洰澶辫触鏃惰鍊煎彂鐢熶綔鐢ㄣ
* @param boolean $reload 寮哄埗閲嶆柊鍔犺浇銆
*/
public static function load_config($file, $key = '', $default = '', $reload = false) {
static $configs = array();
if (!$reload && isset($configs[$file])) {
if (empty($key)) {
return $configs[$file];
} elseif (isset($configs[$file][$key])) {
return $configs[$file][$key];
} else {
return $default;
}
}
$path = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.$file.'.php';
if (file_exists($path)) {
$configs[$file] = include $path;
}
if (empty($key)) {
return $configs[$file];
} elseif (isset($configs[$file][$key])) {
return $configs[$file][$key];
} else {
return $default;
}
}
澶嶅埗浠g爜
娆㈣繋鍏変复 孙民选个人论坛 (http://www.sunminxuan.cn/bbs/)
Powered by Discuz! X3.4