源代码清除BOM标记工具(php版本)
来源:互联网 发布:飞行燃料走淘宝 编辑:程序博客网 时间:2024/06/11 03:35
<?php// 设定你要清除BOM的根目录(会自动扫描所有子目录和文件)$HOME = dirname(__FILE__);// 如果是Windows系统,修改为:$WIN = 1;$WIN = 0;?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>UTF8 BOM CLEAN</title><style>body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; background: #FFF; color: #000; }.FOUND { color: #F30; font-size: 14px; font-weight: bold; }</style></head><body><?php$BOMBED = array();RecursiveFolder($HOME);echo '<h2>These files had UTF8 BOM, but i cleaned them:</h2><p class="FOUND">';foreach ($BOMBED as $utf) { echo $utf ."<br />\n"; }echo '</p>';// 递归扫描function RecursiveFolder($sHOME) { global $BOMBED, $WIN; $win32 = ($WIN == 1) ? "\\" : "/"; $folder = dir($sHOME); $foundfolders = array(); while ($file = $folder->read()) { if($file != "." and $file != "..") { if(filetype($sHOME . $win32 . $file) == "dir"){ $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file; } else { $content = file_get_contents($sHOME . $win32 . $file); $BOM = SearchBOM($content); if ($BOM) { $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file; // 移出BOM信息 $content = substr($content,3); // 写回到原始文件 file_put_contents($sHOME . $win32 . $file, $content); } } } } $folder->close(); if(count($foundfolders) > 0) { foreach ($foundfolders as $folder) { RecursiveFolder($folder, $win32); } }}// 搜索当前文件是否有BOMfunction SearchBOM($string) { if(substr($string,0,3) == pack("CCC",0xef,0xbb,0xbf)) return true; return false;}?></body></html>
0 0
- 源代码清除BOM标记工具(php版本)
- Php批量去除bom工具源代码
- Php批量去除bom工具源代码
- BOM清除工具
- php清除BOM
- php清除bom
- php 清除文件的Bom
- PHP批量清除bom头
- Php去除UTF-8中的BOM标记
- (转)标记-清除算法
- 工具清除BOM解决织梦dedecms后台
- 标记-清除
- 标记-清除
- 清除文件夹下bom代码——php
- PHP检测并清除文件开头的BOM
- 批量清除和检测bom的php代码
- php 源代码审计工具
- php制作bom批量去除工具
- ActionBar 的运用
- 缓存 PHP opcode
- eclipse jquery 报错
- 文章9:Nginx模块开发详细介绍--以HelloWorld模块为例
- 解决getOutputStream() has already been called for this response
- 源代码清除BOM标记工具(php版本)
- UVA 10020 Minimal Coverage 排序+贪心
- C# 调用存储过程
- C语言分层设计模式简介
- 分享一下金黄色系统图标
- Windows 2003 Server安全配置完整篇
- 黑马程序员-IOS-OC基础-内存管理
- 租约
- 我所信仰的