Think\Config类的parse方法 支持自动识别 解析文件类型

Config::parse('my_config.ini','ini');
可以简化成
Config::parse('my_config.ini');
This commit is contained in:
thinkphp
2013-04-03 13:47:12 +08:00
parent 9bfd2bd319
commit 263598458f

View File

@@ -19,7 +19,10 @@ class Config {
}
// 解析其他格式的配置参数
static public function parse($config,$type,$range=''){
static public function parse($config,$type='',$range=''){
if(empty($type)) {
$type = strtolower(substr(strrchr($config, '.'),1));
}
$class = '\Think\Config\Driver\\'.ucwords($type);
self::set((new $class())->parse($config),'',$range);
}