Let Json understand Chinese better (JSON_UNESCAPED_UNICODE)_PHP tutorial

WBOY
Release: 2016-07-21 15:23:25
Original
1119 people have browsed it

Copy code The code is as follows:

echo json_encode("Chinese"); //"u4e2du6587"

This gives those of us who are doing development in Tianchao a headache, and sometimes we have to write json_encode ourselves.

And in PHP5.4, this problem is finally solved Solution, Json has added a new option: JSON_UNESCAPED_UNICODE, hence the name, that is, Json does not need to be encoded in Unicode.

Look at the following example:
Copy code The code is as follows:

echo json_encode("中文", JSON_UNESCAPED_UNICODE); //"中文"


How about it? Is it a change that makes everyone happy? Haha, of course, Json also added: JSON_BIGINT_AS_STRING, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES and other options in 5.4. If you are interested, you can refer to: json_encode

However, a reminder: PHP 5.4 is still in the development stage, and any new features may be adjusted or changed before the final release. If you have any suggestions, feedback is also welcome to help us make PHP better. .
From: http://www.laruence.com

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324501.htmlTechArticleCopy the code code as follows: ?php echo json_encode("Chinese"); //"u4e2du6587" Let us These students who are doing development in Tianchao have a lot of headaches. Sometimes they have to write json_e themselves...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!