批量取出PHP BOM头
来源:互联网 发布:ubuntu ftp路径设置 编辑:程序博客网 时间:2024/05/18 02:32
保存为PHP文件运行一下- <?php
- if (isset($_GET['dir'])){ //设置文件目录
- $basedir=$_GET['dir'];
- }else{
- $basedir = '.';
- }
- $auto = 1;
- checkdir($basedir);
- function checkdir($basedir){
- if ($dh = opendir($basedir)) {
- while (($file = readdir($dh)) !== false) {
- if ($file != '.' && $file != '..'){
- if (!is_dir($basedir."/".$file)) {
- echo "filename: $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 found, automatically removed.</font>");
- } else {
- return ("<font color=red>BOM found.</font>");
- }
- }
- else return ("BOM Not Found.");
- }
- function rewrite ($filename, $data) {
- $filenum = fopen($filename, "w");
- flock($filenum, LOCK_EX);
- fwrite($filenum, $data);
- fclose($filenum);
- }
- ?>
0 0
- 批量取出PHP BOM头
- PHP批量清除bom头
- php 批量去除bom头方法
- PHP去除BOM头
- PHP去除BOM头
- php 去除 BOM头
- PHP去除BOM头
- PHP BOM文件头
- PHP去除BOM头
- PHP去除BOM头
- PHP批量移除UTF-8文件BOM头的代码实例
- PHP批量检测并去除文件BOM头代码实例 导致空白行解决办法
- php程序去掉bom头
- PHP检查是否BOM头
- PHP BOM头的问题
- php批量删除bom头,经常弄导出excel的也看看了啊!(已经测试非常管用)
- PHP去BOM头的方法
- 【PHP】一个bom头引发的血案
- 剑指offer--面试题22:栈的压入、弹出序列--Java实现
- Spring的配置说明
- Android SDK 百度网盘下载
- Numpy的tile函数
- Redis数据类型之LIST类型
- 批量取出PHP BOM头
- 【华为oj】图片整理
- 使用sysfs创建LED驱动
- 第二十三讲 用if语句实现分支结构
- (PHP)微信公众平台模拟登陆和发送消息详解
- opennebula v4.10设计和安装指导 一
- QT入门心得
- linux shell脚本学习xargs命令使用详解
- C#面向对象第六天总结