获取指定key的配置
若不传key,则返回Core_Config对象,可获取动态配置,例如Core::config()->get();
Config Core_Core::config( [ string $key = null , mixed $default = null ] )
参数列表
参数 类型 描述 默认值 $key
string
$key null $default
mixed
默认值 null
Config
array
public static function config($key = null, $default = null)
{
if (null===$key)
{
return Core::factory('Config');
}
$c = explode('.', $key);
$cname = array_shift($c);
if (strtolower($cname)=='core')
{
$v = Core::$core_config;
}
elseif (isset(Core::$config[$cname]))
{
$v = Core::$config[$cname];
}
else
{
return $default;
}
if ($c)foreach ($c as $i)
{
if (!isset($v[$i]))return $default;
$v = $v[$i];
}
return $v;
}