PHP no data (NULL) solution when reading JSON, Phpjson
When using PHP to invoke some JSON interface files, if you use file_get_contents to get the page JSON data
After using Json_decode (), the data cannot be output properly. The return value is null
This is due to PHP file_get_contents obtained data in front of three invisible BOM characters, the PHP transcoding or set the head code to no BOM still cannot solve
One possible approach is to:
$strfile_get_contents// get page address $strsubstr($ STR// due to PHP problem file_get_contents The data is preceded by three invisible BOM characters using the SUBSTR function to extract the contents of the third character $json = Json_decode ($strtrue); // parsing JSON code returned as an array value Echo $json [' MOTD ']; // output An array of MOTD in JSON with an array
Another type of:
PHP$strfile_get_contents// get page address $json = Json_decode (trim( $str,chr(239). CHR (187). CHR (191)),true//chr (239). chr (187). CHR (191) The BOM header that formed the UTF8 file at output, and then removed it with the trim function Print_r($json// output JSON with array
http://www.bkjia.com/PHPjc/1140692.html www.bkjia.com true http://www.bkjia.com/PHPjc/1140692.html techarticle PHP does not have data (empty) solution when reading JSON, Phpjson when using PHP to call some JSON interface files if you use file_get_contents to get the page JSON data and then use the Json_decode ( ...