在common文件中配置
if (!function_exists('get_config')) {
/**
* 获取网站自定义配置文件信息
* @param string $name //字段名称
* @param string $type //所在的组
* @return array|string
*/
function get_config($name = '', $type = 'site_config', $exec = false)
{
if (false === $config = cache($type)) {
model('Config')->webConfig($type);
$config = cache($type);
}
// $config = cache($type);
$config = (isset($config[$name]) && $name) ? $config[$name] : ($name ? '' : $config);
if ($exec) {
$config = html_entity_decode($config);
}
return $config;
}
}
名词解释
这是一个 PHP 函数,用于获取应用中的配置项。具体来说,这个函数会先尝试从缓存中获取指定类型的配置项,如果缓存不存在,则会调用 model('Config')->webConfig($type)
方法来重新生