This article introduces an example of php receiving post data and parsing json for your reference. Php receives post data, parses json code, and uses the php functions stripslashes, json_decode, and var_dump:
Code description: first, get the value of the POST form field txt_json in the html file, put it in the variable $ json_string, and then make a judgment. 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, so it needs to be reversed. After the definition is reversed, the json_decode function is used to convert the JSON text into an object and save it in the $ user variable. echo var_dump ($ user); is used to output the dump of the object. Appendix: php json data parsing code PHP parses JSON data code. it always knows how to parse various transfer formats of API data, including JSON and XML. Run the following code to parse the data obtained from POST on A Renren website:
name; //prints fooecho $obj->interest[1]; //prints php?> |