中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

批量去除PHP文件中bom的PHP代碼

需要去除BOM,就把附件里的tool.php文件放到目標(biāo)目錄,然后在瀏覽器訪問tool.php即可!
復(fù)制代碼 代碼如下:
<?php
//此文件用于快速測(cè)試UTF8編碼的文件是不是加了BOM,并可自動(dòng)移除
$basedir="."; //修改此行為需要檢測(cè)的目錄,點(diǎn)表示當(dāng)前目錄
$auto=1; //是否自動(dòng)移除發(fā)現(xiàn)的BOM信息。1為是,0為否。
//以下不用改動(dòng)
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file!='.' && $file!='..' && !is_dir($basedir."/".$file))
echo "filename: $file ".checkBOM("$basedir/$file")." <br>";
}
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);
}
?>

php批量去除php文件中bom的代碼
復(fù)制代碼 代碼如下:
<?php
if (isset($_GET['dir'])){ //設(shè)置文件目錄
$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._<a href=http://www.joyphper.NET>http://www.joyphper.NET</a></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);
}
?>

php技術(shù)批量去除PHP文件中bom的PHP代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产在线第一页 | 一区二区三区四区五区在线视频 | 97久久精品午夜一区二区 | 亚洲一区二区三区在线播放 | 青青久草 | 日韩国产欧美在线观看 | 久在线 | 日本国产欧美 | 黄色片视频网站 | 99精品欧美一区二区三区综合在线 | 在线观看国产三级 | 蜜桃视频一区二区三区 | 欧美精品福利视频 | 日韩伦理一区二区 | 亚洲天堂av在线 | 羞视频在线观看 | 日韩国产一区二区 | 天天操欧美 | 久久久精彩视频 | 99re视频 | 久久精品国产一区二区三区不卡 | 中国一级大黄大片 | 国产乱码精品一品二品 | 麻豆一区二区三区 | www.中文字幕 | 天天躁日日躁狠狠躁白人 | 国产精品美女久久久久久久久久久 | 色橹橹欧美在线观看视频高清 | 欧美日韩在线一区 | 中文字幕成人av | 国产成人精品午夜 | 久久国产精品一区二区三区 | 国产亚洲高清视频 | 狠狠干天天干 | 国产成人99久久亚洲综合精品 | 亚洲视频免费在线观看 | 亚洲国产一区视频 | 日本精品在线一区 | 在线不卡一区 | xxxxx免费视频 | 毛片a级|