發(fā)表日期:2018-06 文章編輯:小燈 瀏覽次數(shù):3153
配置文件配置在caches/configs/目錄下。
配置文件調(diào)用:使用load_config方法
/**
* 加載配置文件
* @param string $file 配置文件
* @param string $key 要獲取的配置薦
* @param string $default 默認(rèn)配置。當(dāng)獲取配置項(xiàng)目失敗時(shí)該值發(fā)生作用。
* @param boolean $reload 強(qiáng)制重新加載。
*/
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;
}
}
示例:
調(diào)用系統(tǒng)配置中的附件路徑
$upload_url = pc_base::load_config('system','upload_url');
日期:2018-06 瀏覽次數(shù):3428
日期:2018-06 瀏覽次數(shù):3253
日期:2018-06 瀏覽次數(shù):3297
日期:2018-06 瀏覽次數(shù):3273
日期:2018-06 瀏覽次數(shù):3082
日期:2018-06 瀏覽次數(shù):3294
日期:2018-06 瀏覽次數(shù):3119
日期:2018-06 瀏覽次數(shù):3258
日期:2018-06 瀏覽次數(shù):3408
日期:2018-06 瀏覽次數(shù):3152
日期:2018-06 瀏覽次數(shù):2903
日期:2018-06 瀏覽次數(shù):2946
日期:2018-06 瀏覽次數(shù):2949
日期:2018-06 瀏覽次數(shù):2626
日期:2018-06 瀏覽次數(shù):2875
日期:2018-06 瀏覽次數(shù):2719
日期:2018-06 瀏覽次數(shù):2631
日期:2018-06 瀏覽次數(shù):2819
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.