PHP Bulk Removal BOM Header code share, Phpbom header code
<?php/*** Removal of BOM header information */header ("content-type:text/html; Charset=utf-8 "); $auto = 1; Checkdir ("D:\wamp\www\sales"); function Checkdir ($basedir) {if ($dh = Opendir ($basedir)) {while (($file = Readdir ($DH))!== false) {if ($file! = '. ') && $file! = ' ... ') {if (!is_dir ($basedir. ") /". $file)" {echo "file name: $basedir/$file". Checkbom ("$basedir/$file"). "
"; }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 ("Found BOM and deleted automatically"); } else {return ("Find BOM"); }} else return ("No BOM found"); The function rewrite ($filename, $data) {$filenum = fopen ($filename, "w"), Flock ($filenum, LOCK_EX); Fwrite ($filenum, $data ); Fclose ($filenum); }?>
http://www.bkjia.com/PHPjc/1022786.html www.bkjia.com true http://www.bkjia.com/PHPjc/1022786.html techarticle php Bulk Removal BOM Header code sharing, Phpbom header code php/*** removal of BOM header information */header ("content-type:text/html; Charset=utf-8 "); $auto = 1; Checkdir ("D:\wamp\www\sales"); Function ...