//清除Bom节点

$basedir = str_replace('/clearBOM.php','',str_replace('\\','/',dirname(__FILE__)));

$auto = 1;

checkdir($basedir);

function checkdir($basedir){

if ($dh = opendir($basedir)) {

while (($file = readdir($dh)) !== false) {

if ($file != '.' && $file != '..'){

if (!is_dir($basedir.'/'.$file)) {

$filename = $basedir.'/'.$file;

echo 'filename:'.$basedir.'/'.$file.checkBOM($filename).'
';

} 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 'BOM found,automatically removed.';

} else {

return 'BOM found.';

}

} else {

return 'BOM Not Found.';

}

}

function rewrite ($filename, $data) {

$filenum = fopen($filename, 'w');

flock($filenum, LOCK_EX);

fwrite($filenum, $data);

fclose($filenum);

}

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

clearbom.php,clearBOM.php相关推荐

最新文章

  1. 最初的梦想,将来的你一定会感谢现在努力的自己
  2. 验证ArrayList插入同样数据使用指定容量和默认容量的效率
  3. linux 统计_聊聊 Linux 的内存统计
  4. spark基础之spark streaming的checkpoint机制
  5. HTML Table 冻结行列
  6. html语言中表格由什么组成,html表格基本结构是什么?html表格的完整代码详解
  7. Struts2反序列化漏洞复现
  8. 小笔记-简单但够用系列_informix静默安装
  9. android程序劫持持程序,大谈android安全2——Activity劫持的防范程序
  10. 提高谷歌浏览器下载速度
  11. 交换机接口的双工模式
  12. 【转帖】绝版破解软件教程就不信你学不会!!
  13. Open3D 点云投影至指定球面(Python版本)
  14. 4.5 拉普拉斯定理
  15. matlab 反激实例(S440_Flyback.slx)
  16. 通过 JS 添加样式
  17. 个人草根站长如何靠广告联盟赚钱
  18. 软件版本号详解,Alpha、Beta、RC、Stable、Release、GA、RTM、RTL、OEM、
  19. Win10PE_V2.0Nvme网络版.iso 支持Nvme硬盘免费下载无需积分
  20. 扫地机器人的轮子困住_小米扫地机器人轮子在运行中悬空怎么办?怎么清理传感器?...

热门文章

  1. 116. 飞行员兄弟【二进制枚举】
  2. 【AC Saber】数据结构
  3. 项目: 图片放大缩小。
  4. Shell中的if判断
  5. python之lxml处理xml
  6. Spring boot的静态资源映射
  7. JSP页面Table的数据拼接
  8. MySQL字符串和二进制
  9. matlab mbuild setup,关于mbuild的一个问题
  10. java 快排_百度在年前会在打击一轮快排!