PHP json output has?? , CSS style is not normal, remove PHP BOM Header

Source: Internet
Author: User

//Just save the file as removebom.php, place it in the root of the server, and then execute it to remove the server-side BOM.
At the start of a little red dot in chrome

1<?PHP2 //Remove the Utf-8 BOMs3 //by magicbug at gmail dot com4 if(isset($_get[' dir ']) {//config the Basedir5 $basedir=$_get[' dir '];6}Else{7 $basedir= '. ';8 } 9 $auto= 1; TenCheckdir ($basedir); One functionCheckdir ($basedir){ A if($DH=Opendir($basedir)) { - while(($file=Readdir($DH)) !==false) { - if($file! = '. ' &&$file! = ' ... '){ the if(!Is_dir($basedir." /".$file)) { - Echo"FileName:$basedir/ - $file". Checkbom ("$basedir/$file")." <br> "; -}Else{ + $dirname=$basedir." /". - $file; +Checkdir ($dirname); A } at } - } - Closedir($DH); - } - } - in functionCheckbom ($filename) { - Global $auto; to $contents=file_get_contents($filename); + $charset[1] =substr($contents, 0, 1); - $charset[2] =substr($contents, 1, 1); the $charset[3] =substr($contents, 2, 1); * if(Ord($charset[1]) = = 239 &&Ord($charset[2]) = = 187 && $ Ord($charset[3]) = = 191) {Panax Notoginseng if($auto= = 1) { - $rest=substr($contents-R); theRewrite ($filename,$rest); + return("<font Color=red>bom found, AAutomatically removed.</font> "); the}Else { + return("<font Color=red>bom found. -</font> "); $ } $ } - Else return("BOM not Found.")); - } the - functionRewrite ($filename,$data) {Wuyi $filenum=fopen($filename, "W"); the Flock($filenum,lock_ex); - fwrite($filenum,$data); Wu fclose($filenum); - } About?>

PHP json output has?? , CSS style is not normal, remove PHP BOM Header

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.