Home >Backend Development >PHP Tutorial >Simple example of PHP filtering BOM data in the page

Simple example of PHP filtering BOM data in the page

WBOY
WBOYOriginal
2016-07-25 08:51:251370browse
  1. /**
  2. * Filter the bom in the page
  3. * edit bbs.it-home.org
  4. */
  5. function checkBOM ($filename) {
  6. $contents = file_get_contents($filename);
  7. $charset[1] = substr($contents, 0, 1);
  8. $charset[2] = substr($contents, 1, 1);
  9. $charset[3] = substr($contents, 2, 1);
  10. if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {
  11. $rest = substr($contents, 3);
  12. rewrite $rest;
  13. }else{
  14.  return false;
  15. }
  16. }
  17. ?>
复制代码


Statement:
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