PHP Learning notes 7-json data manipulation, PHP learning notes 7-json_php Tutorials

Source: Internet
Author: User

PHP Learning notes 7-json data manipulation, PHP learning notes 7-json


JSON, the full name is JavaScript Object Notation. It is a lightweight data interchange format based on the JavaScript programming language ECMA-262 3rd Edition-december 1999 standard, mainly used for exchanging data with the server. Similar to XML, its independent language has a great advantage in cross-platform data transmission.

Create a new file json.php, do the encode operation first:

1 // encode 2 //Generate JSON-formatted data 3 $arr Array (1,2,3,4,5,6,7,8,9, ' Hello ', ' PHP '); 4 echo json_encode ($arr); // Json_encode: Converting an object to JSON-formatted data

The resulting result is [1,2,3,4,5,6,7,8,9, "Hello", "PHP"]

Again to do decode operation:

1 // Decode decoding 2 $jsonStr = ' {' h ': ' Hello ', ' W ': ' World ', ' 0 ': [3,2,1]} '; 3 $obj = Json_decode ($jsonStr); 4 Echo $obj->h; // results can be obtained by using the member access method

Knowing the simple way to use, you can try to catch the API data, such as the weather ...

http://www.bkjia.com/PHPjc/1023839.html www.bkjia.com true http://www.bkjia.com/PHPjc/1023839.html techarticle PHP Learning notes 7-json data manipulation, PHP learning notes 7-json JSON, full name is JavaScript Object Notation. It is based on the JavaScript programming language ECMA-262 3rd edition-december 1999 Standard ...

  • Related Article

    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.