search
Homephp教程php手册在PHP使用json_encode

在PHP使用json_encode

Jun 13, 2016 am 11:34 AM
encodejsonphpxexchangeuseexiststartdataFormatoflightweight

Json 做为一种轻量级的数据交换格式,开始受到亲睐,有与 XML 抢地盘的风头。而让人高兴的是,php也把 json 序列化数据的功能内置成函数了,这让想使用json的 PHPCoder 备感方便。
美中不足的是,json_encode / json_decode 系列函数只有在 php5.2 以上才有。这让立志开发兼容性强的PHP系统的coder很头痛。
幸好,已经有人把 json 的方法封装成 php4.x 系列甚至更低的版本都可以执行的类了。这里要先谢谢先驱了。让我们可以踩在巨人的肩膀上走向成功。

这里了解更多:http://code.itlearner.com/php/JSON-class.html

  使用方法:

 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);


 }


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools