예제 #1
0
파일: Fun.php 프로젝트: skschoo1/framework
/**
 * C 读取配置文件
 * @param  string	$name
 * @param  mixed	$value
 * @return
 */
function C($name = '', $value = '')
{
    if (!empty($name)) {
        $Config = new \Skschool\Config();
        if (empty($value)) {
            $rs = $Config->get($name);
        } else {
            $rs = $Config->set($name, $value);
        }
        return $rs;
    } else {
        trigger_error('IS NOT SETTING NAME');
    }
}
예제 #2
0
 public function config()
 {
     /**
      * use Skschool\Config;
      */
     // 获取配置文件
     echo Config::get('error_page');
     // 获取全部配置文件
     /* $list = Config::all();
     		p($list); */
     // 动态修改配置文件  增加  || 修改
     // $status = Config::set('error_page', 'abc.com');
     // echo '修改配置文件状态: '.$status;
 }
예제 #3
0
 /**
  * 合并配置文件
  * @access	public
  * @return 	void
  */
 public static function mergeConfig()
 {
     $config_path1 = APP_ROOT . 'config/config.php';
     if (!file_exists($config_path1)) {
         trigger_error('Not Find ' . $config_path1);
     }
     $config_path2 = APP_ROOT . 'config/databases.php';
     if (!file_exists($config_path2)) {
         trigger_error('Not Find ' . $config_path2);
     }
     $config = array_merge(require $config_path1, require $config_path2);
     if (!empty($config['load_ext_config'])) {
         $arr_config = explode(',', $config['load_ext_config']);
         foreach ($arr_config as $v) {
             $tmp = APP_ROOT . 'config/' . $v . '.php';
             if (file_exists($tmp)) {
                 $config = array_merge($config, require $tmp);
             } else {
                 trigger_error('Not Find ' . $tmp . ', Beacuse load_ext_config setting.');
             }
         }
     }
     Config::$_config = $config;
     $routes_path = APP_ROOT . 'config/routes.php';
     if (!file_exists($routes_path)) {
         trigger_error('Not Find ' . $routes_path);
     }
     require $routes_path;
 }