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
http://www.bkjia.com/PHPjc/324501.htmlwww.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...
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