8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

phpcms v9二次开发:配置文件调用

IT171中文网 管理员组 2013-7-17 731

[indent] /**
* 加载配置文件
* @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;
  }
}
[/indent]
来源:网络转载[hr]
最新回复 (6)
全部楼主
  • 已认证 游客 游客组@Ta 2014-7-4
    引用 2
    [该用户未绑定手机,内容不能显示]
  • 已认证 游客 游客组@Ta 2014-7-17
    引用 3
    [该用户未绑定手机,内容不能显示]
  • 已认证 游客 游客组@Ta 2014-9-20
    引用 4
    [该用户未绑定手机,内容不能显示]
  • guduao 一级用户组@Ta 2015-4-10
    引用 5
    [该用户未绑定手机,内容不能显示]
返回
发新帖
我也是有底线哒~