Today, when you are working on a project, include the file with the include statement. Test on the cloud server is normal, on the virtual host is always more strange strange line breaks or whitespace. The problem is as follows:
The troubleshooting found that the problem appears on the page encoding of the containing file: the encoding of the included file is stored Utf-8+bom encoding. Convert file to utf-8 no BOM encoding format is good;
Here's what we learned in this troubleshooting, summarized below:
1. What is a BOM?
A BOM is a token that is used to determine which Unicode encoding a text file is, and is itself a Unicode character ("\ufeff") located at the head of a text file. UTF-8 actually consists of two formats: UTF-8 no BOM type and UTF-8 have BOM type. The main problem is the type with BOM. In fact, in the UTF-16 UTF-32 the same points with the BOM and no BOM two kinds.
2. What are the existing problems?
The BOM is actually a very useful prefix. But in the case of server point-to-point communication or Web page display in some cases is redundant or will bring "trouble". For example, a garbled character such as the following is added to the page header: "" Nobelium? "
1. For example, when we combine several JS files into a single file, if the middle of the file contains BOM characters, it will cause the browser JS syntax error.
2.PHP does not recognize the BOM header, PHP does not ignore the BOM, so when reading, including or referencing these files, the BOM is used as part of the text at the beginning of the file. Depending on the characteristics of the embedded language, this string of characters will be executed directly (shown). As a result, even if the top padding of the page is set to 0, there is no way to keep the entire page close to the top of the browser, because there are 3 characters at the beginning of the HTML!
3 File Encoding Conversion method
I use the EditPlus editor to convert, as follows, the document menu--File encoding--Batch conversion encoding (Files encoding multiple), select all files and then transcode, and then save all.
Expansion-extra spaces or line breaks when resolving PHP output
1. To find out if you have an echo or exit space or a newline,
2. Make sure that there are no extra carriage returns, <?php?> tags in php files. If it is a purely php script file, delete the end tag after the script
3. After these are cleared, if it is a UTF8 encoded file, it will also output an extra space to enter. When making XML transmissions, you often die on this extra blank. This is caused by the BOM file header. Save as a document without a BOM.
When a PHP include statement contains a file, the browser wraps more lines