// 去除BOM function qcbom(){ $sql = new Baksql(\think\Config::get("database")); $allfiles = $sql->allfiles(ROOT_PATH); foreach($allfiles as $file){ if(stristr($file,'.php')||stristr($file,'.html')||stristr($file,'.txt')){ if(file_exists($file)){ $str = file_get_contents($file); if($this->SearchBOM($str)){ echo $file.'<br>'; $str = substr($str, 3); file_put_contents($file, $str); } } } } exit; } // 搜索当前文件是否有BOM function SearchBOM($string) { if(substr($string,0,3) == pack("CCC",0xef,0xbb,0xbf)) return true; return false; }