The html meta and link generated by php are marked with an empty line at the top of the body Tag.

Source: Internet
Author: User
Tags smarty template ultraedit

1. html generated using the smarty template in php has a blank line at the top of the browser.

2. Use firedebug to find that meta and link are marked in the body tag.

Wmap runs fine on the local machine. It is an IASP service that is sent to a remote server. The above bug will occur.

After reading the source file, the text is the same, but the encoding problem is prompted during saving. It is estimated that the problem is caused by UTF-8.

I found it online. It is a UTF-8 BOM problem.

Solution: Use UltraEdit32 to save all the template files (such as include headers and footer files) referenced by the smarty template file as UTF-8 files without BOM.

Other supplementary instructions:

The page uses UTF8 encoding, And the template containing the document is used for the header and tail. The result header and tail have an empty line of about 10 PX, and there is nothing left.

The reason is that all files are UTF-8 encoded. when documents are included, the final binary stream contains multiple utf8 BOM tags. IE cannot parse pages containing multiple UTF8 BOM tags normally, directly replace it with the actual displayed carriage return, which leads to a blank line, but firefox does not.

Therefore, if the template uses the included method to contain multiple utf8 documents, you need to use the ultraedit save as function to select utf8 without bom format to save.

In addition, if the Chinese page places the title tag in <meta http-equiv = "Content-type" Content = "text/html; the front of Charset = UTF-8 '/> causes a blank page.

Therefore, standard order should be used for utf8 pages
Copy codeThe Code is as follows:
<Meta http-equiv = "Content-type" Content = "text/html; Charset = UTF-8"/>
<Meta http-equiv = "Content-language" Content = "zh-CN"/>
<Meta name = "robots" Content = "index, follow"/>
<Meta name = "keywords" Content = ""/>
<Meta name = "desCription" Content = ""/>
<Meta name = "rating" Content = "general"/>
<Meta name = "author" Content = ""/>
<Meta name = "Copyright" Content = ""/>
<Meta name = "generator" Content = ""/>
<Title> </title>

BOM header: \ xEF \ xBB \ xBF, PHP scripts 4 and 5 still ignore BOM, so it is directly output before parsing.

This w3.org standard FAQ provides a special description of this issue:

Www.w3.org/International/questions/qa-utf8-bom

The details are as follows:

There is a char named "zero width no-break space" in the UCS encoding, and its encoding is FEFF. FFFE does not exist in the UCS, so it should not appear in actual transmission. We recommend that you transmit the char "zero width no-break space" before transmitting the byte stream ". In this way, if the receiver receives FEFF, it indicates that the byte stream is Big-Endian; if it receives FFFE, it indicates that the byte stream is Little-Endian. Therefore, char "zero width no-break space" is also called BOM.

The UTF-8 does not need BOM to indicate the byte order, but BOM can be used to indicate the encoding method. The UTF-8 code for char "zero width no-break space" is ef bb bf. So if the receiver receives a byte stream starting with ef bb bf, it will know that this is UTF-8 encoding.

In Windows, BOM is used to mark the encoding method of text documents. The default char set is Chinese.

1) notepad: It can automatically identify UTF-8 encoded documents without bom, but cannot control whether to add bom when saving the document. If you save the document, the bom will be added in a unified manner.

2) editplus: Can not automatically identify the UTF-8 encoding format documents without bom, when saving the document, select the UTF-8 format, will not write BOM header in the document.

3) UltraEdit: the most powerful function for char encoding. You can automatically identify the UTF-8 documents with and without bom (which can be configured). You can choose whether to add bom by configuring the saved files.
(Note that when saving a new document, you must save it as UTF-8 no bom)

Later, we found that Notepad ++ also provides better support for the UTF-8 bom. We recommend that you use it.

Related Article

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.