关于作业
来源:3-6 【Config底层类库分析二】load加载深度分析
一场丶
2019-04-17
在think\config\driver 下增加两个类 Php.php 和 Yaml.php
class Php
{
protected $config;
public function __construct($config)
{
$this->config = $config;
}
public function parse()
{
return include $this->config;
}
}
class Yaml
{
protected $config;
public function __construct($config)
{
$this->config = $config;
}
public function parse()
{
return yaml_parse_file($this->config);
}
}
然后 \think\Config.php 中注释掉判断语句
protected function loadFile($file, $name)
{
$name = strtolower($name);
$type = pathinfo($file, PATHINFO_EXTENSION);
// if ('php' == $type) {
// return $this->set(include $file, $name);
// } elseif ('yaml' == $type && function_exists('yaml_parse_file')) {
// return $this->set(yaml_parse_file($file), $name);
// }
return $this->parse($file, $type, $name);
}
写回答
1回答
-
singwa
2019-04-17
嗯,很棒
012019-12-30
相似问题