A blank section (#65279 characters?) appears at the top of the HTML page generated by PHP ?) Solution

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.