您好,欢迎访问一九零五行业门户网

去除文件BOM头工具_PHP教程

':'只检测文件bom不执行去除bom操作
';checkdir($basedir,$loop);function checkdir($basedir='',$loop=true){ $basedir=empty($basedir)?'.':$basedir; if($dh=opendir($basedir)){ while (($file=readdir($dh))!==false){ if($file!='.'&&$file!='..'){ if(!is_dir($basedir.'/'.$file)){ echo '文件: '.$basedir.'/'.$file .checkbom($basedir.'/'.$file).'
'; }else{ if(!$loop) continue; $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并已自动去除'); }else{ return (' 找到bom'); } }else{ return (' 没有找到bom'); }}function rewrite($filename,$data){ $filenum=fopen($filename,'w'); flock($filenum,lock_ex); fwrite($filenum,$data); fclose($filenum);}
http://www.bkjia.com/phpjc/778931.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/778931.htmltecharticle? php /* * * 用法:复制以下代码至新建的php文件中,将该php文件放置项目目录,运行即可。代码来源于网络。 * chenwei 注。 */ header ('content-...
其它类似信息

推荐信息