Home >Backend Development >PHP Tutorial >Why Is My PHP AJAX Response Text Failing String Comparisons?
Avoiding Character 65279 Echoing in PHP
When receiving a response via AJAX callback, you may encounter an issue where the retrieved text (xmlhttp.responseText) appears correct, but comparisons against a specific string yield false results. This is often caused by the presence of an invisible character with a charCodeAt(0) of 65279.
Understanding Character 65279
Character 65279 is a Unicode Control Character (Unicode codepoint U FEFF) that specifies the endianness of the Unicode encoding:
Causes of Character 65279 Echoing
Character 65279 is typically added to UTF-8 encoded files by editors like Windows Notepad. When a PHP file is included into another, it can introduce this character, resulting in unexpected behavior.
Solution
To avoid character 65279 echoing, you can:
The above is the detailed content of Why Is My PHP AJAX Response Text Failing String Comparisons?. For more information, please follow other related articles on the PHP Chinese website!