Xiaotan Vim opens at the beginning of the file

WBOY
Release: 2016-08-08 09:19:37
Original
1217 people have browsed it

After uploading the PHP program developed on the local Windows machine to the Linux server, I accessed the corresponding interface through the browser and found that there was an inexplicable character '-' in front of the returned data. I was very puzzled. Afterwards, through network packet capture, we found that there were more EF BB BF before the interface returned data. It's always extremely frustrating to have bugs like this happen for no apparent reason. After several attempts, it still couldn't be solved, but I also vaguely felt that it might be a character encoding problem, so I used PHPStorm to create a new file, and then rewritten the contents of the previously buggy file (fortunately, the file was not too big). Yes, if you use svn, you should roll the file back to the previous bug-free version) and then upload it again. The problem is actually solved. I gave it up in joy without delving into the reasons. G originally thought that the bug was lifted, and after that, I encountered it again, and I couldn't bear it. This time, the method of viewing the code is not to change it on the local machine and then re-upload it to the server, but to open it directly on the server with vim and view it line by line. The result was a surprise. The vim file header showed an extra ‘’ character. I intuitively told myself that this was the culprit. So we further explored the character.

Here we first talk about utf8, utf16, and utf32 encoding. Because this encoding corresponds to multiple bytes, generally utf16 and utf32 will use BOM (Byte Order Mark, which is an invisible character) to identify internally encoded words. Endian (Big/Little Endian), and utf8 can be added with or without BOM. Generally, the utf8 encoding of the editor we use does not add a BOM identifier, but Notepad under Windows will add a BOM identifier in front of the utf8 encoded file. This BOM logo corresponds to the character that appears after vim is opened in the Linux environment. The character will appear in , when PHP parses such a file, it will output this character, which leads to the above bug.

PS: It’s better to use Notepad less to open or edit utf8 encoded codes, a bloody lesson! ! !

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces the

at the beginning of the file opened by Xiaotan Vim, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!