好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

解决织梦换服务器引起的页面不居中错位问题

解决织梦换服务器引起的页面不居中错位问题

页面之所以错位是因为utf8格式的文件多了BOM头,只要把这些BOM头去掉就可以了,php代码如下,保存成php文件放在根目录中执行一次就行了,会自动去除文件头中的BOM.

记住不要用记事本,用其他的文本编辑器.

//remove the utf-8 boms   //by magicbug at gmail dot com   if  (isset( $_GET [ 'dir' ])){  //要去除的文件目录,无参数则为文件当前目录。   $basedir = $_GET [ 'dir' ];  } else {  $basedir  =  '.' ;  }  $auto  = 1;  checkdir( $basedir );  function  checkdir( $basedir ){  if  ( $dh  = opendir( $basedir )) {      while  (( $file  = readdir( $dh )) !== false) {       if  ( $file  !=  '.'  &&  $file  !=  '..' ){        if  (! is_dir ( $basedir . "/" . $file )) {         echo  "filename:  $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  ( "BOM found,automatically removed." );     }  else  {       return  ( "BOM found." );     }  //phpfensi测试数据   }  else   return  ( "BOM Not Found." );  }  function  rewrite ( $filename ,  $data ) {  $filenum  =  fopen ( $filename ,  "w" );  flock ( $filenum , LOCK_EX);  fwrite( $filenum ,  $data );  fclose( $filenum );  }

查看更多关于解决织梦换服务器引起的页面不居中错位问题的详细内容...

  阅读:58次