php BOM problem

Nov 10, 2016 am 09:44 AM
bom

In recent collaborative development projects, I always found that the output of PHP was wrong. The code was exactly the same and it didn't work. Later, I thought there was a problem with the encoding and found out that they were all utf-8. Finally, after deleting the file contents, I found that there were still 3 characters in size. Use the vim -b command. After opening it, I found and I feel like the problem lies here.

Later I found out that this is the BOM in utf-8. What's disgusting is that the BOM will be output along with the echo, causing errors.

Attached are a few commands to find and remove BOM

In vim:

Java code

#Set UTF-8 encoding

:set fileencoding=utf-8

#Add BOM

:set bomb

#Delete BOM

:set nobomb

#Query BOM

:set bomb?

grep:

Java code

//Find

grep -I -r -l $'xEFxBBxBF' / path

//Replacement

grep -I -r -l $'xEFxBBxBF' /path | xargs sed -i 's/^xEFxBBxBF//g'

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
What are the dom and bom objects? What are the dom and bom objects? Nov 13, 2023 am 10:52 AM

There are 5 DOM objects including "document", "element", "Node", "Event" and "Window"; 2. "window", "navigator", "location" and "history" and "screen" and other 5 BOM objects.

What is the difference between bom and dom What is the difference between bom and dom Nov 13, 2023 pm 03:23 PM

BOM and DOM are different in terms of role and function, relationship with JavaScript, interdependence, compatibility of different browsers, and security considerations. Detailed introduction: 1. Role and function. The main function of BOM is to operate the browser window. It provides direct access and control of the browser window. The main function of DOM is to convert the web document into an object tree, allowing developers to Use this object tree to obtain and modify the elements and content of the web page; 2. Relationship with JavaScript, etc.

Explore the meaning and function of PHP bom Explore the meaning and function of PHP bom Mar 10, 2024 pm 10:45 PM

The meaning and function of PHPbom In PHP programming, BOM (ByteOrderMark) is a special character sequence used to identify the encoding method and byte order of the file. The BOM is usually inserted at the beginning of the file to allow the parser to identify the encoding, especially for some encoding formats that do not start with ASCII encoding, such as UTF-8. BOM has different functions in different encoding formats. The following will specifically explore the meaning and function of BOM in PHP, and combine it with code examples to add

What do dom and bom achieve? What do dom and bom achieve? Nov 20, 2023 pm 02:28 PM

DOM enables dynamic access and updates to web page content, while BOM provides APIs for interacting with browser windows, including controlling browser behavior and obtaining information about the browser and user environment. DOM is mainly used to operate web page content, while BOM is mainly used to operate browser windows and interact with browsers. The two together form an important foundation in Web front-end development, providing developers with rich methods to control and operate web pages and browsers to achieve strong interactivity, Web applications with good user experience.

What is PHP bom? Detailed analysis What is PHP bom? Detailed analysis Mar 10, 2024 am 11:42 AM

Sorry, I can't provide an article on PHPbom issues. Are there any other questions I can help you with?

What models are bom and dom? What models are bom and dom? Nov 13, 2023 pm 05:08 PM

BOM is the browser object model, and DOM is the document object model. BOM is a model used to describe browser windows and various objects provided by the browser. It is the core component of the browser. BOM can access and operate objects such as browser windows and frames. DOM provides a set of APIs that enable developers to access and manipulate elements and attributes in documents through scripting languages. Its core concepts include nodes, elements, attributes, text, etc. The root node of the DOM tree is the document object, through which Access the entire document's content.

What is the difference between front-end BOM and DOM? What is the difference between front-end BOM and DOM? Nov 13, 2023 pm 02:36 PM

The differences are: 1. Different meanings, BOM refers to the browser object model, and DOM refers to the document object model; 2. Different structures, BOM is centered on the browser window, and the elements in the DOM document are represented as nodes and arranged in a tree shape. The structure is organized; 3. The interaction methods are different, BOM interacts with JS through the Window object, and DOM interacts through nesting and references between objects; 4. The application scope is different, BOM is used for the interaction between the browser window and the browser, DOM is used for the operation and interaction of document content; 5. Different development trends, etc.

How to remove bom from php code How to remove bom from php code Oct 20, 2022 am 09:29 AM

Methods to remove BOM from PHP code: 1. Use the "function clearbom($contents){...}" method to remove the BOM header in the text; 2. Use the "function checkBOM ($filename) {...}" method to detect and Remove the BOM header; 3. Use the "function SearchBOM($string) {...}" method to search whether the current file has a BOM and remove it.

See all articles