Xiaotan Vim opens at the beginning of the file
Aug 08, 2016 am 09:19 AM
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 ‘<feff>’ character. I intuitively told myself that this was the culprit. So we further explored the <feff> 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 <feff> character that appears after vim is opened in the Linux environment. The <feff> character will appear in <?php ...?>, 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.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

How to enable or disable taskbar thumbnail previews on Windows 11

OOBELANGUAGE Error Problems in Windows 11/10 Repair

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari?
