Page layout appears blank

Source: Internet
Author: User

The top of the page more than a blank line, even caused the pattern of the confusion, the style is set up, but there are blank lines. Very strange, and then search for a bit, find out why. is because the page encoding when added to the BOM, the resulting blank line, how to go away.


Analysis Reason:
Because UTF-8 encoding is used, it is saved in the Utf-8 encoding format after the code is written or modified. Although almost all of the text editing software now can display and edit UTF-8 encoded files, unfortunately many of these software performance is not ideal.

Software such as Windows-brought Notepad, when saving a UTF-8 encoded file, inserts three invisible characters (_0xef _0xbb _0xbf, Bom--byte Order Mark) where the file begins. It is a string of hidden characters that allows editors such as Notepad to identify whether the file is encoded in UTF-8. For general files, this does not cause any trouble. But for PHP, PHP at design time does not consider the problem of the BOM, do not ignore the UTF-8 encoded file at the beginning of the BOM three characters, will be the BOM as part of the text at the beginning of the file. Because it must be in <? or the code behind the <?php will be executed as PHP code, so it will result in the output of the three characters on the page, the display effect is to see the browser, is usually a blank line or a garbled character. Because of the existence of these 3 characters at the beginning of the HTML, even if the top padding of the page is set to 0, the entire page cannot be kept close to the top of the browser. Due to the limitations of the cookie delivery mechanism, cookies cannot be sent in files that have a BOM at the beginning of these files (because PHP has sent the file header before the cookie is sent), so the login and logout functions fail. All the functions that rely on cookies and session implementations are not valid.

Workaround:

When editing or changing any text file, be sure to use an editor that does not mess with the BOM. The editor under Linux should not have this problem. Under Windows, do not use editors such as Notepad.

The recommended editors are:
1, EditPlus 2.12 version or more;
2, EmEditor;
3, UltraEdit (need to cancel the "add BOM" relevant options);
4, Dreamweaver (need to cancel the ' Add BOM ' related options);
5, Notepad (need to "convert to non-BOM UTF-8") and so on.
6, for the file has been added to the BOM, to cancel, you can use the above editor to save one time. (EditPlus needs to be saved as GB first and then saved as UTF-8.) ) Recommended for EditPlus.

Page layout appears blank

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.