When using PHP's Json_encode to process Chinese, Chinese will be coded, become unreadable, resemble "u***" format, and increase the amount of data transferred to some extent.
The code is as follows |
Copy Code |
<?php Echo Json_encode ("Chinese"); Output: "u4e2du6587" |
This let us do development in the celestial students, is very headache, sometimes also have to write their own json_encode.
In PHP5.4, the problem was finally resolved, and JSON added an option: Json_unescaped_unicode, hence the name incredible, which means that JSON does not encode UNICODE.
Look at the following example:
The code is as follows |
Copy Code |
<?php Echo Json_encode ("Chinese", json_unescaped_unicode); Output: "Chinese" |
What, is it a change that makes everyone happy?
Oh, of course, JSON also added in 5.4: json_bigint_as_string, Json_pretty_print, json_unescaped_slashes, etc.