我正在尝试学习Yii来处理一个名为HumHub的项目,但是文档中缺乏示例,而且我对框架一般都非常非常陌生。通常情况下,我是根据我不同寻常的强迫症思想来发展自己的。
http://www.yiiframework.com/doc/api/1.1/CJSON
如何使用CJSON类读取json文件并将其用作vars?
发布于 2015-01-12 04:55:53
您可以将javascript文本解码为php变量,但首先您必须将文件读成如下所示的文本:
$json_text = file_get_contents('file.json');
// or the yii way
$json_text = $this->renderPartial('path.to.file.json', null, true, true);
// then decode it
$var = json_decode($json_text);
// or the yii way
$var = CJSON::decode($json_text);https://stackoverflow.com/questions/27895472
复制相似问题