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