首页 > Web开发 > 详细

使用php清除bom示例

时间:2016-01-30 08:34:01      阅读:198      评论:0      收藏:0      [点我收藏+]

复制代码 代码如下:

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 ("<font color=red>BOM found, automatically removed.</font>"); 

           }else { 

              return ("<font color=red>BOM found.</font>"); 

           } 

       }else return ("BOM Not Found."); 

    } 

使用php清除bom示例

原文:http://www.jb51.net/article/47546.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!