源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

使用php清除bom示例

  • 时间:2020-11-08 23:45 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:使用php清除bom示例
核心代码
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清除莫明输出大法,用于输出图片前把前面所有输出清空 只要在header前连用两个函数,就可以解决...
ob_get_clean();
ob_clean();
header("Content-type: image/jpeg");
附几个好用的BOM检测工具: [url=http://www.1sucai.cn/softs/496779.html]BOM检测.zip[/url] [img]http://files.jb51.net/file_images/article/201609/20160924161923.png[/img] [img]http://files.jb51.net/file_images/article/201609/20160924161924.png[/img]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部