Home  >  Article  >  Backend Development  >  Tutorial on using json_encode_PHP in PHP

Tutorial on using json_encode_PHP in PHP

WBOY
WBOYOriginal
2016-07-21 14:51:35825browse

As a lightweight data exchange format, Json has begun to gain popularity and competes with XML for the limelight. What is gratifying is that PHP has also built-in the function of json serialized data as a function, which makes PHPCoder who want to use json very convenient.
The only drawback is that the json_encode / json_decode series of functions are only available in php5.2 and above. This gives coders who are determined to develop a highly compatible PHP system a headache.
Fortunately, someone has already encapsulated the json method into a class that can be executed by the php4.x series or even lower versions. I would like to thank the pioneer in advance. Let us step on the shoulders of giants and achieve 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);


}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371739.htmlTechArticleJson, as a lightweight data exchange format, has begun to gain popularity and is competing with XML for territory. Limelight. What makes people happy is that PHP has also built-in the function of json serialized data into a function...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn