Php does not have data (empty) when reading json. it is phpjson. Php does not have data (empty) when reading json, when phpjson is used to call some json interface files in PHP, if file_get_contents is used to obtain json data on the page and then json_decode is used (php does not read json data (it is empty), phpjson
When PHP is used to call some json interface files, if file_get_contents is used to obtain the page json data
After json_decode () is used for parsing, data cannot be normally output. the returned value is null.
This is because the data obtained by file_get_contents in php contains three BOM characters that cannot be seen before it. it still cannot be solved if php transcoding or header encoding is no BOM
One feasible method is:
$ Str = file_get_contents ('json interface address'); // Obtain the page address $ str = substr ($ str, 3 ); // due to a php problem, the data obtained by file_get_contents contains three BOM characters that cannot be seen before it. use the substr function to extract the content after the third character $ json = json_decode ($ str, true ); // Parse the json code and return the array value echo $ json ['motd ']; // output the motd array in json with array
Another type:
Solution for Callback (empty): When PHP is used to call some json interface files, if file_get_contents is used to obtain json data on the page, then json_decode (...