发表日期:2018-06 文章编辑:小灯 浏览次数:2567
配置文件配置在caches/configs/目录下。
配置文件调用:使用load_config方法
/**
* 加载配置文件
* @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;
}
}
示例:
调用系统配置中的附件路径
$upload_url = pc_base::load_config('system','upload_url');
日期:2018-06 浏览次数:2824
日期:2018-06 浏览次数:2689
日期:2018-06 浏览次数:2704
日期:2018-06 浏览次数:2698
日期:2018-06 浏览次数:2525
日期:2018-06 浏览次数:2566
日期:2018-06 浏览次数:2531
日期:2018-06 浏览次数:2694
日期:2018-06 浏览次数:2644
日期:2018-06 浏览次数:2567
日期:2018-06 浏览次数:2419
日期:2018-06 浏览次数:2474
日期:2018-06 浏览次数:2180
日期:2018-06 浏览次数:2146
日期:2018-06 浏览次数:2393
日期:2018-06 浏览次数:2243
日期:2018-06 浏览次数:2128
日期:2018-06 浏览次数:2364
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.