TP5无法载入json配置文件

浏览:1543 发布日期:2016/07/29 分类:ThinkPHP5专区 关键字: TP5,配置加载
json内容如下:{
"default_module":"Index",
"url_model":2,
"session_auto_start":true
}
test控制器内容如下:namespace app\admin\controller;
use think\Config;
class Index extends Controller
{
public function test()
    {
        $test = Config::parse(APP_PATH . 'config.json');
        dump($test);
        $test = file_get_contents(APP_PATH . 'config.json');
        dump($test);
        dump(json_decode($test));
    }
}
输出如下:
NULL

string(71) "{
"default_module":"Index",
"url_model":2,
"session_auto_start":true
}
"

object(stdClass)#18 (3) {
["default_module"] => string(5) "Index"
["url_model"] => int(2)
["session_auto_start"] => bool(true)
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>