A blank section (#65279 characters?) appears at the top of the HTML page generated by PHP ?) Solution: recently, the ThinkPHP framework is used in the project, and the top of a page is always blank.
As shown in:
It only appears in chrome and edge browsers, and ff does not. The page is spliced by a PHP + HTML template, so the html file, JavaScript file, and PHP file are checked successively. No problems found.
Chrome F12 is used to find that the blank space is a string of delimiter characters. Through the search, I learned that this was the problem of UTF-8 encoding.
I am using the encoding is UTF-8 + BOM, this encoding method will usually appear in the windows operating system, such as WINDOWS built-in notepad and other software, when saving a file encoded in UTF-8, three invisible characters (0xEF 0xBB 0xBF, BOM) are inserted at the beginning of the file ). It is a string of hidden characters, used for the notepad editor to identify whether the file is encoded in UTF-8. For general files, this will not cause any trouble. However, BOM is a big headache for PHP. Because PHP does not ignore BOM, BOM is used as part of the beginning body of the file when reading, including, or referencing these files. According to the characteristics of the embedded language, this string of characters will be directly executed (displayed.
After knowing the cause of the problem, we can solve it well. I am using phpstorm and there is the "remove bom" option in the menu bar file, which can be saved directly as a UTF-8 without BOM mode. If you use notepad ++ or other tools, you can also select save as, and then select UTF-8 without BOM in the encoding to solve.