Simple example of PHP filtering BOM data in the page

WBOY
Release: 2016-07-25 08:51:25
Original
1329 people have browsed it
  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. ?>
复制代码


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!