Home > Backend Development > PHP Tutorial > Reasons and solutions for why a blank space appears at the top when previewing a PHP file in a browser, affecting layout analysis_PHP Tutorial

Reasons and solutions for why a blank space appears at the top when previewing a PHP file in a browser, affecting layout analysis_PHP Tutorial

WBOY
Release: 2016-07-21 15:14:09
Original
1018 people have browsed it

During the process of writing the PHP file, I found that when previewing the PHP file in the browser, a blank line would appear at the top, which affected the layout of the page.

The explanation of BOM header is as follows:

Normally, the notepad program that comes with the Windows system is used to write web page programs, but when writing or modifying the php blog system After coding, the following problems will always appear when debugging:

–Cannot log in or log out;
–A blank line appears at the top of the page;
–An error warning appears at the top of the page;
–Other abnormal situations.

Analysis reasons:
Due to the use of UTF-8 encoding, after writing or modifying the code, it is saved in UTF-8 encoding format. Although almost all text editing software now can display and edit UTF-8 encoded files, unfortunately, the performance of many of them is not ideal.

When software such as Notepad that comes with Windows saves a file encoded in UTF-8, three invisible characters (_0xEF _0xBB _0xBF, or BOM——) will be inserted at the beginning of the file. Byte Order Mark). It is a string of hidden characters used to let editors such as Notepad identify whether the file is encoded in UTF-8. For ordinary files, this will not cause any trouble. But for PHP, PHP did not consider the BOM issue when designing. It will not ignore the three characters of the BOM at the beginning of the UTF-8 encoded file, and will use the BOM as part of the beginning text of the file. Since the code after
Solution:

When editing or changing any text file, please be sure to use an editor that does not add BOM randomly. Editors under Linux should not have this problem. Under WINDOWS, please do not use editors such as Notepad. The recommended editors are:
Editplus version 2.12 or above;
EmEditor;
UltraEdit (need to cancel the related options of 'Add BOM');
Dreamweaver (need to cancel the related options of 'Add BOM') ;
Notepad (requires "Convert to UTF-8 without BOM"), etc.

For files that have added BOM, if you want to cancel, you can use the above editor to save it once. (Editplus needs to save as gb first, and then save as UTF-8. Dreamweaver can cancel "Contain Unicode Signature (BOM)" in "Page Properties")

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326364.htmlTechArticleDuring the process of writing the PHP file, I found that when previewing the PHP file in the browser, a blank line would appear at the top, which affected The layout of the page. The explanation of BOM header is as follows: Normally, use...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template