Home  >  Article  >  php教程  >  张进杰-ThinkPHP 3.1.3 去除网站头部的白条

张进杰-ThinkPHP 3.1.3 去除网站头部的白条

WBOY
WBOYOriginal
2016-06-16 08:41:151259browse

ThinkPHP 3.1.3 去除网站头部的白条。ThinkPHP 去除网站头部的白条,联系专业工程师 QQ467477957
当你的网站项目头部无缘无故出现了一条白条,这个是utf8文件编码可能是utf8-bom。如果不是,文件本身编码问题的话!那就是thinkphp自身对文件进行utf-8-bom编码,此时去掉白条的方法就是,在项目根目录,执行bob.php代码!ok了

http://www.3bkstore.com/bob.php
张进杰-ThinkPHP 3.1.3 去除网站头部的白条
张进杰-ThinkPHP 3.1.3 去除网站头部的白条

bob.php<?php <br /> if (isset($_GET['dir'])){ //设置文件目录   <br> $basedir=$_GET['dir'];   <br> }else{   <br> $basedir = '.';   <br> }   <br> $auto = 1;   <br> checkdir($basedir); <br> function checkdir($basedir){   <br> if ($dh = opendir($basedir)) {   <br>   while (($file = readdir($dh)) !== false) {   <br>    if ($file != '.' && $file != '..'){   <br>     if (!is_dir($basedir."/".$file)) {   <br>      echo "filename: $basedir/$file ".checkBOM("$basedir/$file")." <br>";   <br>     }else{   <br>      $dirname = $basedir."/".$file;   <br>      checkdir($dirname);   <br>     }   <br>    }   <br>   }   <br> closedir($dh);   <br> }   <br> } <br> <br> function checkBOM ($filename) {   <br> global $auto;   <br> $contents = file_get_contents($filename);   <br> $charset[1] = substr($contents, 0, 1);   <br> $charset[2] = substr($contents, 1, 1);   <br> $charset[3] = substr($contents, 2, 1);   <br> if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {   <br>   if ($auto == 1) {   <br>    $rest = substr($contents, 3);   <br>    rewrite ($filename, $rest);   <br>    return ("<font>BOM found, automatically removed.</font>");   <br>   } else {   <br>    return ("<font>BOM found.</font>");   <br>   }   <br> }   <br> else return ("BOM Not Found.");   <br> }   <br> function rewrite ($filename, $data) {   <br> $filenum = fopen($filename, "w");   <br> flock($filenum, LOCK_EX);   <br> fwrite($filenum, $data);   <br> fclose($filenum);   <br> }   <br> ?>

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn