Why is the layout affected by blank content on the top of the browser when previewing the php file and the solution?

Source: Internet
Author: User
During php file preparation, a blank line is displayed on the top of the browser when previewing the php file, which affects the page layout, A blank line will appear on the top, affecting the page layout.

The BOM header is described as follows::

Generally, you can use the notepad program that comes with Windows to write web programs. However, after you write or modify the code of the php blog system, the following problems always occur during debugging:

-You cannot log in or log out;
-A blank line appears at the top of the page;
-An error warning is displayed on the top of the page;
-Other abnormal situations.

Cause analysis:
Because UTF-8 encoding is used, the code is saved as UTF-8 encoding format after being written or modified. Although almost all text editing software can now display and edit UTF-8-encoded files, it is a pity that many of them are not doing well.

Similar to WINDOWS Notepad and other software, when saving a file encoded in UTF-8, will insert three invisible characters at the beginning of the file (_ 0xEF _ 0xBB _ 0xBF, BOM -- Byte Order Mark ). 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. But for PHP, PHP did not consider the BOM issue during design, does not ignore the three characters at the beginning of the UTF-8-encoded file BOM, the BOM is used as a part of the beginning body of the file. Because it must be in
Solution:

When editing or changing any text files, you must use an editor without adding BOM. The editor in Linux should have no such problem. In WINDOWS, do not use notepad or other editors. The recommended editor is:
Editplus version 2.12 or later;
EmEditor;
UltraEdit (you need to cancel the related options of 'add BOM );
Dreamweaver (you need to cancel the related options of 'add BOM );
Notepad (to convert to UTF-8 without BOM) and so on.

If you want to cancel a file that has been added with BOM, you can use the editor above to save it again. (Editplus needs to be saved as gb first, then as UTF-8. Dreamweaver can cancel the "contain Unicode signature (BOM)" in the "Page attribute)

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.