Echoing of Character 65279 in PHP: Causes and Remedies
When performing an AJAX callback and comparing the XMLHTTP request response to a string, developers may encounter a discrepancy due to the presence of an invisible character prepended to the response. This character, often identified as 65279 using charCodeAt(0), is known as a UTF-8 control character indicating the encoding type.
To determine the origin of this character, it's crucial to understand that Windows Notepad adds a BOM (Byte Order Mark) to UTF-8 encoded files, consisting of three bytes (EF BB BF). While PHP does not explicitly handle the BOM, problems arise when including one PHP file into another.
Solution:
There are multiple options to resolve the issue:
These solutions effectively remove the BOM character from the included file, preventing the unexpected addition of character 65279.
The above is the detailed content of Why Does My PHP AJAX Callback Have an Extra Character (65279) at the Beginning?. For more information, please follow other related articles on the PHP Chinese website!