JSON exception returned by php

Source: Internet
Author: User
Unknown characters before the json returned by php through the json_encode ($ rst) function {& quot; status & quot;: & quot; OK & quot;} cause parsing failure, what should I do? Php functions Json_encode ($ rst)Unknown characters appear before the returned json �� {"Status": "OK "}
What should I do if the resolution fails?

Reply content:

Php functionsJson_encode ($ rst)Unknown characters appear before the returned json�� {"Status": "OK "}
What should I do if the resolution fails?

Because the problem may not be caused by the current php document, which may have been accumulated by a previous document and is inconvenient for troubleshooting, it can be used before output.Ob_clean ();Clear the preceding output cache.

Supplement: you can use "grep-rlI $ '\ xEF \ xBB \ xBF'." to globally find files with bom encoding.

Php file encoding

Set the file encoding.

The json processing function of php only supports UTF-8 encoding for Chinese characters.

Change the output JSON file encoding format to UTF8 without BOM

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.