thinkphp 框架去掉bom(当你的网站出现头部有一条空白)
来源:互联网 发布:ubuntu syslog 过大 编辑:程序博客网 时间:2024/05/16 12:12
当你的项目头部无缘无故出现了一条白条,这个是utf8文件编码可能是utf8-bom如果不是,文件本身编码问题的话!那木就是thinkphp自身对文件进行utf-8-bom编码,此时去掉白条的方法就是,在项目根目录,执行此段代码!ok了
<?php
if(isset($_GET['dir'])){ //config the basedir
$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")."<br>";
}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("<font color=red>BOM found,automatically removed.</font>");
} else{
return("<font color=red>BOM found.</font>");
}
}
else return("BOM Not Found.");
}
function rewrite ($filename, $data) {
$filenum= fopen($filename, "w");
flock($filenum, LOCK_EX);
fwrite($filenum, $data);
fclose($filenum);
}
?>
- thinkphp 框架去掉bom(当你的网站出现头部有一条空白)
- PHP文件头BOM带来的困惑(frameset无法显示,头部一行空白)
- PHP文件头BOM带来的困惑(frameset无法显示,头部一行空白)
- ios7UITableView 的头部出现一段空白View
- iOS7CollectionView有空白头部的解决方案
- thinkphp 出现bom 头
- thinkphp 出现bom 头
- 用 ThinkPHP 这样的框架开发门户网站,有什么缺点?(讨论)
- UITableViewStyleGrouped类型下去掉头部空白
- php文件引用头部有空白行()
- 怎么去除table多余出来的行,我的table里面只显示一条记录,但是下面出现很多空白的行,要怎么去掉
- UITableView 当滚动的时候会有多出的空白,去掉空白的方法
- thinkphp框架做的网站
- thinkphp #65279 出现小块空白
- thinkphp 模板页面出现空白
- php页面用include引入header.php出现头部上边有一行空白
- 页面头部出现空白,页面头部出现 隐藏字符
- 文字编码utf-8无bom格式(网站页面出现空白行)
- C++ Primer 1-3
- Maven自动构建工具笔记
- 不懂技术的人不要对懂技术的人说这很容易实现
- 红帽操作系统——初学笔记(一)
- ImageView scaleType 属性解析
- thinkphp 框架去掉bom(当你的网站出现头部有一条空白)
- p2p终结者,汇报csdn广大码农。
- 代码覆盖率浅谈
- 《揭秘CAN-bus不被人关注的重要知识点》(1)
- 机器学习Learning中的代数结构的建立
- dedecms获取图片集多张图片方法(循环输出)
- C++ Primer 7-9
- 什么是网站流量?如何计算?
- jquery 插件 阅读