How can I remove the UTF-8 bom header?

Source: Internet
Author: User
Tags flock
How can I remove the UTF-8 bom header? Google, 360 browser, and QQ browser have bom headers on the top of the webpage; Firefox browser shows normal.
I tried a variety of methods (Dreamweaver, Notepad ++, and I searched for a program file to remove bom on the Internet). In the end, I still failed to solve the problem. do you have any other solutions?

This section shows the bom in Google's browser:


Reply to discussion (solution)

The file itself has Chinese characters, directly save as BOM urf-8 encoding
If the file itself does not contain Chinese characters, it is saved as ANSI encoding.

In terms of multilingual versions, the program files should not contain texts in specific languages. Instead, it fills the content in the dictionary at runtime.

The file itself has Chinese characters, directly save as BOM urf-8 encoding
If the file itself does not contain Chinese characters, it is saved as ANSI encoding.

In terms of multilingual versions, the program files should not contain texts in specific languages. Instead, it fills the content in the dictionary at runtime.



I just saved it as UTF-8 without bom in the editor, but it still doesn't work, but it works in Firefox. Why?

Have all the related files been done?

Not all browsers can ignore the BOM header.

If netbeans is installed, use it to open the file,
If the file has a bom header, a small dot is displayed at the beginning of the first line. delete the dot and save it.

Have all the related files been done?

Not all browsers can ignore the BOM header.



This is my program
 ";                  }else{ $dirname = $basedir."/".$file;                      checkdir($dirname);                  }              }          }      closedir($dh);      } } function checkBOM ($filename) { global $auto; $contents = file_get_contents($filename); $charset[1] = substr($contents, 0, 1);  $charset[2] = substr($contents, 1, 1); $charset[3] = substr($contents, 2, 1);  if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) { if ($auto == 1) { $rest = substr($contents, 3);              rewrite ($filename, $rest); return ("BOM found, automatically removed.");          } else { return ("BOM found.");          }      }  else return ("BOM Not Found."); } function rewrite ($filename, $data) {$filenum = fopen($filename, "w");      flock($filenum, LOCK_EX);      fwrite($filenum, $data);      fclose($filenum); }

I cannot use this to remove bom.

This program is effective for deleting the UTF-8 BOM.

You can check it out.

$s = file_get_contents('http://localhost');echo bin2hex($s);
Paste the first 20 characters of the output

This program is effective for deleting the UTF-8 BOM.

You can check it out.

$s = file_get_contents('http://localhost');echo bin2hex($s);
Paste the first 20 characters of the output


Is this code stored in the bom file?

From your perspective, there are tokens
This should be the BOM header of unicode. determine whether the internal code value of the first two characters of the file is 255 and 254.

The code is run in a single program.

From your perspective, there are tokens
This should be the BOM header of unicode. determine whether the internal code value of the first two characters of the file is 255 and 254.


The output starts with the first one.

The code is run in a single program.


This is executed separately.

You #10 have 3 UTF-8 BOM
You #11 do not have BOM

You #10 have 3 UTF-8 BOM
You #11 do not have BOM



Why?

Remove the bom from all the first-off files.
The location of your program is very important. besides, you may also reference files outside the website.

Remove the bom from all the first-off files.
The location of your program is very important. besides, you may also reference files outside the website.

My bom program is placed in the project root directory, which is a sibling relationship with other files.

If you delete the bom of all the files in the project, and there is a bom in the page
This means that you have used files other than the project.

If you delete the bom of all the files in the project, and there is a bom in the page
This means that you have used files other than the project.


I have a big head, but I still cannot find it. thank you.

Then you can run the bom program on the root of the website.

Then you can run the bom program on the root of the website.



I suspect this has something to do with some JavaScript files. some program files on the website are written in js.

Do you think JavaScript files are not related files?

Do you think JavaScript files are not related files?




I just removed the js code on the homepage of the website.

Do you think JavaScript files are not related files?


Because the path in this section of js is hm. src = "// hm.baidu.com/hm.js? 54403e32d263feb8a8a2d4a630ccc73f ";
It is related to it by mistake.

Is your website on the Internet? Post the website

Is your website on the Internet? Post the website


Http://www.25mj.com/

There are 3 bom
Please post index. php

There are 3 bom
Please post index. php

 
 
 
 [Official website of Oriental Mercure] China's leading decoration-building materials-e-commerce website in the household field, professional decoration building materials and furniture consumption guide platform
 
 
 
 
 
 

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.