• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP批量去除BOM头代码分享_php实例

php 搞代码 3年前 (2022-01-25) 21次浏览 已收录 0个评论
<?php /*** 去除bom头信息*/header("Content-Type:text/html; charset=utf-8"); $auto = 1; checkdir("D:\wamp\www\sales"); function checkdir($basedir){ if ($dh = opendir($basedir)) {  while (($file = readdir($dh)) !== false) {   if ($file != '.' && $file != '..'){   if (!is_dir($basedir."/".$file))<b style="color:transparent">来&源gao@dai!ma.com搞$代^码%网</b><img>搞gaodaima代码</img> {    echo "文件名称: $basedir/$file ".checkBOM("$basedir/$file")." <br>";   }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 ("<font color="red">发现BOM并且已自动删除</font>");  } else {   return ("<font color="red">发现BOM</font>");  } } else return ("没有发现BOM"); } function rewrite ($filename, $data) { $filenum = fopen($filename, "w"); flock($filenum, LOCK_EX); fwrite($filenum, $data); fclose($filenum); } ?>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP批量去除BOM头代码分享_php实例
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址