Eliminating the Echo of Character 65279 in PHP
When encountering a false return when comparing an XMLHTTP request text to a string, it's essential to consider the possibility of an "invisible character" at the string's beginning, often represented by a character code of 65279. This character is an UTF-8 control character that signifies big-endian or small-endian encoding.
The root cause of this issue lies in the addition of a BOM (Byte Order Mark) character by Windows Notepad when saving files in UTF-8 encoding. This BOM consists of 3 bytes: EF BB BF. While PHP typically ignores this character, issues arise when including one PHP file into another, resulting in strings being displayed with character 65279 prepended.
To resolve this issue, it's recommended to use alternative text editors like Notepad and select the "Encode in UTF-8 without BOM" option when saving files. This prevents Notepad from adding the BOM character.
Alternatively, you can save the other PHP file with ANSI encoding in Notepad. This approach is suitable if no extended characters are used in the file. By implementing these solutions, you can effectively eliminate the echo of character 65279 and ensure accurate string comparisons.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3