This article mainly introduces the PHP batch removal project Document BOM head method, has a certain reference value, now share to everyone, the need for friends can refer to
1 <?php 2 if (isset ($_get[' dir ')) {//Set file directory 3 $basedir = $_get[' dir '); 4} else {5 $basedir = '. '; 6} 7 8 $auto = 1; 9 Checkdir ($basedir); The function Checkdir ($basedir) {($DH = Opendir ($basedir)) {($file = Readdir ($DH)) {) False) {[$file! = '. ' && $file! = ' ... ') {!is_dir ($basedir. "/" . $file) {echo "filename: $basedir/$file". Checkbom ("$basedir/$file"). "<br>"; * else {$dirname = $basedir. "/" . $file; Checkdir ($dirname); +} ($DH); ($filename) ($auto), and the $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) { PNS $rest = substr ($contents, 3); Rewrite ($filename, $rest); ("<font color= ' red ' >bom found, automatically removed.</font>"); ' Else {' <font color= ' red ' >bom found.</font> '); ("BOM not Found."); Rewrite ($filename, $data) $filenum = fopen ($filename, "w"), Flock ($filenum, lock_e X); Wuyi fwrite ($filenum, $data); Fclose ($filenum); ?>
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!