我有一个包含以下内容的 .json 文件:
{ "questions": "reponse" }
我想将文件的内容解析成一个 PHP 数组,但我有一个奇怪的问题......
$path = 'myFile.json';
echo file_get_contents($path);
echo var_dump(json_decode(file_get_contents($path), true));
echo var_dump(json_decode(utf8_encode(file_get_contents($path), true)));
$json = '{ "questions": "reponse" }';
echo var_dump(json_decode($json, true));
我屏幕上的结果是:
{ "questions": "reponse" }
null
null
array (size=1)
'questions' => string 'reponse' (length=7)
文件中的字符串和我程序中的字符串有什么区别?
谢谢!