Teach you how to use PHP to output Chinese JSON strings
json_endoce: http://cn.php.net/json_encode json_dedoce: http://cn.php.net/json_decode
json_encode — JSON encodes the variable and returns the JSON form of the value, for example:
<?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); ?>
The output after the above code is executed:
{"a":1,"b":2,"c":3,"d":4,"e":5}
If the data source to be encoded (generally is an array), the value contains Chinese, and the output after json_encode processing is unicode encoding.
<?php $arr = array ('a'=>'脚本之家'); echo json_encode($arr); ?>
The output after the above code is executed:
{"a":"\u811a\u672c\u4e4b\u5bb6"}
The bottom layer of PHP has been processed by unicode. If you think it is not intuitive enough, you can use the urlencode and urldecode methods to bypass the process of transcoding to unicode:
$arr = array ('a'=>urlencode('PHP中文网')); echo urldecode(json_encode($arr));
After the above code is executed, the output is:
{"a":"PHP中文网"}
For more related articles that teach you how to use PHP to output Chinese JSON strings, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
