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