Influence of BOM of UTF-8 on PHP

Source: Internet
Author: User

After loading a frameset framework template when writing code with notepad ++ today, this page is not displayed on the page, and it is normal after you view the source code. Then, simply delete all the items in it and write a few test texts to display them normally.

Tossing for a long time, finally accidentally saw two control templates PHP file is not the same as a UTF-8 without BOM encoding another is UTF-8 format encoding, try to change the UTF-8 format to the UTF-8 without BOM format. Save and open firefox. The frameset template that is not displayed before is displayed. Then I tried it in chrome and did not display it. Then I thought about whether there were other PHP file formats not converted into BOM-free formats. I checked all the UTF-8 are changed to the UTF-8 without BOM format after saving chrome can be normally displayed. I finally breathed a sigh of relief.

I have been concerned with UTF-8 and UTF-8 without BOM this format. So Baidu checked their differences. It is roughly as follows:

UTF-8 files can be divided into two formats: no BOM and BOM.

What is BOM? "Ef bb bf" is called BOM. The full name of BOM is "Byte Order Mard ". In UTF-8 files, BOM is often used to indicate that this file is a UTF-8 file, and BOM is really utf16 used to represent the high and low byte sequence. Prior to the byte stream, BOM indicates that the low byte sequence is used (the low byte is at the front), while utf8 does not need to consider the byte sequence, so it is possible to have BOM. The UTF-8 is encoded in bytes and there is no issue of bytecode. The UTF-16 uses two bytes as the encoding unit. before interpreting a UTF-16 text, you must first understand the byte order of each encoding unit. For example, if the Unicode encoding of "queue" is 594E and that of "B" is 4E59. If we receive the UTF-16 byte stream "594E", is this "Kui" or "B "?

If you select BOM when saving the file, the page is not displayed normally.In general, php does not support BOM, php files should be saved as UTF-8 without BOM type

Therefore, do not use BOM when saving the UTF-8 encoded PHP file.

 

 

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.