This article mainly introduces the solution of php parsing the json string variables obtained by http, which is always blank and null. my personal experience is summarized. we recommend this article to you. Today, my colleague encountered a problem in the project. the json string obtained through the http interface cannot be correctly parsed using json_decode, and blank space is returned.
Directly copy the result string and manually create a variable, but it is normal. It can also be parsed in front-end js. after half a day, it cannot be solved, and the powerful Google solves the problem, the answer is that the interface output results contain a BOM header, which is a dead enemy of php.
If you don't talk about it, the solution is as follows:
The code is as follows:
If (substr ($ return, 0, 3) = pack ("CCC", 0xef, 0xbb, 0xbf )){
$ Return = substr ($ return, 3 );
}
$ Data = json_decode ($ return, true );
Here we will record and share it with you, hoping to help you.