您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

快速去除整站程序文件编码中的BOM方法

2024/4/25 17:24:06发布5次查看
今天发现这个方式也是间或,在伏笔主机购买了独立ip空间后,装置指定的网站程序,装置完成后登陆后台时,验证码不显示,空间初始化了几次重新装置后,才初步判定是网站程序文件中有bom体式文件在,常规的是utf-8,他这个是utf-8+bom,所以涌现问题了。只是,这会儿你又不知道确却的文件是哪一个?怎么办勒?
接下来用这个方式,一定管用!
首先,你本土新建一个文件,这里定名为:removebom.php
接着,把下面这段代码复制粘贴进去,上面定名的文件里面,然后保留一下,上传到网站根目次下面,接着直接运行该文件即可!
removebom.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._<a href=http://host.fbi1.net>http://host.fbi1.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); } ?>
上面的代码的作用就是铲除bom的!实际效果异常好,分分钟解决这个问题
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录