Why is the result of converting json_decode to a uft-8 string null?
0) {// $ str = mb_convert_encoding ($ str, "GBK", "UTF-8"); $ jo = json_decode ($ str); // Chinese, the transfer is nullprint_r ("\ n ++ \ n ". $ jo. "\ n ===\ n"); $ msg_id = $ jo-> msg_id; // An error is returned here .} Echo '';?>
Reply to discussion (solution)
Json format is incorrect. you can echo the json string to be converted by j to see if it complies with the standard json format.
A little simpler:
"; Print" $ str = ". $ str. "\ n"; if (strlen ($ str)> 0) {$ jo = json_decode ($ str); // Chinese, the transfer is nullprint_r ("\ n ++ \ n ". $ jo. "\ n ===\ n"); $ msg_id = $ jo-> txt ;}
I saved the t1.php file as UTF-8 encoded.
But still not.
Add the following
It is no longer in json format.
Print_r ("\ n ++ \ n". $ jo. "\ n ===\ n ");
What is it here?
Echo $ _ POST ["text"];
Look at what it is. most of the quotes are escaped.