Several commonly used data interchange formats for PHP

Source: Internet
Author: User

Serialization (serialize), variables, XML, and JSON are some of the 4 common forms of text data exchange in PHP.    First, serialization and deserialization using serialize and unserialize will be any data type (in addition to resources), formatted as a text data format, PHP built-in, the most convenient to use, you can save and restore data, objects and so on.    Benefits: Easy to use, good support.    Not good: No commonality only PHP can support, large text size. Possible: speed may be slow. The variable writes the data into a standard PHP assignment statement in a text file, which is included in the execution of the program and restores the variable by performing an assignment of the value.    Discuz often use this approach as a cache of data.    Benefits: Intuitive.    Bad: No commonality only PHP can support, inconvenient to use, you need to transform the data into an assignment statement, the variable is not flexible reception. Possible: Faster, less storage volume than serialization.    XML Formats the data into XML storage and parsing.    Benefits: Strong versatility, data exchange with other programming languages; PHP already has built-in function support. Bad: The volume of the text is large, and the efficiency of formatting and inverse solution is low. JSON is also a text-based data interchange format similar to XML.    is a new data format for solving the complexity of XML browser data exchange. Benefits: Strong versatility, the current mainstream language has built-in support, 5.2 (please check the manual) version has built-in support. It is convenient to use in the future and is similar to serialization for ease of use. Better compatibility and high efficiency than XML, especially for browsers.    The data format is small in size. Possible: Efficiency issues, especially the efficiency of the analysis.


This article is from the "JSON in PHP use" blog, declined reprint!

Several commonly used data interchange formats for PHP

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.