PHPCMS 配置文件
2016-03-31 19:11
351 查看
PHPCMS配置文件路径:
数据库配置文件位置:caches/configs/database.php
路由配置文件位置:caches/configs/route.php
系统配置文件位置:caches/configs/system.php
。。。。。。
PHPCMS调用配置文件方法:
配置文件配置在caches/configs/目录下。
配置文件调用:使用 load_config方法(该方法位于 base.php 文件中)
/**
* 加载配置文件
* @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');
pc_base::load_config('route', SITE_URL)
pc_base::load_config('database');
数据库配置文件位置:caches/configs/database.php
路由配置文件位置:caches/configs/route.php
系统配置文件位置:caches/configs/system.php
。。。。。。
PHPCMS调用配置文件方法:
配置文件配置在caches/configs/目录下。
配置文件调用:使用 load_config方法(该方法位于 base.php 文件中)
/**
* 加载配置文件
* @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');
pc_base::load_config('route', SITE_URL)
pc_base::load_config('database');
相关文章推荐
- PHPCMS 二次开发技巧
- bzoj 1778 [Usaco2010 Hol]Dotp 驱逐猪猡(高斯消元)
- SCTP协议详解与实例
- thinkphp 中 ajax的使用
- PHPCMS_数据库配置
- 4.1 Zend_Config
- PHP中的连贯操作
- php检查漏洞防护补丁-防护XSS,SQL,文件包含等多种高危漏洞
- ThinkPHP处理海量数据分表机制详细代码
- php输出json格式数据的例子
- ZendFramework-1.12.17
- PHP C扩展初探
- yii框架开启debug和gii
- matplotlib-绘制精美的图表
- php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法
- yii报错400
- sphinx使用步骤
- php中常用的运算符
- php programmer should know?
- update the gedit for php programming(searched not try yet)