Using JSON in PHP

Source: Internet
Author: User
Tags json

Json, as a lightweight data interchange format, is starting to get pro-Lai, with the spotlight of XML grabbing sites. Happily, PHP has also built the functionality of JSON-serialized data into functions, making it easy for Phpcoder to use JSON.
In the ointment, the Json_encode/json_decode series function is only above php5.2. This makes determined to develop a compatible PHP system coder very headache.
Fortunately, the JSON approach has already been encapsulated into classes that can be executed by the php4.x series or even lower versions. Thanks first to the pioneer here. So that we can step on the shoulders of giants to success.

Learn more here: http://code.itlearner.com/php/JSON-class.html

How to use:

if (function_exists ("Json_encode"))


{


Return Json_encode ($phparr);


}


Else


{


Require_once ROOT. " Include/json.class.php ";


$json = new Services_json;


Return $json->encode ($phparr);


}


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.