This article describes how to use PHP to receive POST data and json data. For more information, see
The code is as follows:
$ Json_string = $ _ POST ["txt_json"];
If (ini_get ("magic_quotes_gpc") = "1 ")
{
$ Json_string = stripslashes ($ json_string );
}
$ User = json_decode ($ json_string );
Echo var_dump ($ user );
?>
In this file, first obtain the value of the POST form field txt_json in the html file, put it in the variable $ json_string, and then judge, if the current PHP is set to magic_quotes_gpc = On, that is, the passed double quotation marks will be escaped, so that the json_decode function cannot be parsed. Therefore, we need to reverse it. Then, use the json_decode function to convert the JSON text into an object, save it in the $ user variable, and finally use echo var_dump ($ user); to output the dump of the object.