PHP Json_encode Let JSON understand Chinese (json_unescaped_unicode)

Source: Internet
Author: User
We know that when using PHP Json_encode to deal with Chinese, Chinese will be encoded, become unreadable, similar to the "\u***" format, but also to a certain extent, increase the amount of data transferred.

Echo Json_encode ("Chinese"); Output: "\u4e2d\u6587"

This let us do the development of the students in the celestial, is a headache, and sometimes have to write their own json_encode. In PHP5.4, the problem is finally resolved, JSON added an option: Json_unescaped_unicode, so the name Incredibles, that is, JSON does not encode Unicode.

Look at the following example:

Echo Json_encode ("Chinese", Json_unescaped_unicode); Output: "Chinese"

How, is not let everybody very happy change?

Of course, JSON also joins in 5.4: Json_bigint_as_string, Json_pretty_print, json_unescaped_slashes and other options

If you are interested, you can see: Json_encode

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.