PHP receives post data and parses a simple instance of JSON

Source: Internet
Author: User
Tags php json
in this article, PHP receives the data from post, and parses an example of JSON, for everyone to learn the reference.

PHP receives the post data, parses the JSON code, uses PHP functions--stripslashes, Json_decode, Var_dump:

 

Code Description: First, get the value of the Post form field Txt_json in the HTML file, put in the variable $json_string, and then judge if the current PHP is set to Magic_quotes_gpc=on, That is, the incoming double quotes are escaped so that the Json_decode function cannot be parsed, so it needs to be reversed. After inversion, use the Json_decode function to convert the JSON text to an object, save it in the $user variable, and finally use the Echo var_dump ($user), to output the object dump.

, PHP JSON data parsing code

PHP parsing JSON data code, it is always able to know how to parse the API data of various delivery formats, including Json,xml and so on. The following code resolves the data that everyone connected to the site post obtains:

 
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.