我在Firebug中看到这个角色
.
我不知道为什么会这样,我的代码中没有这样的字符.对于Firefox来说没关系,但在IE中一切都会中断.我甚至无法在Google中搜索此角色.
我用utf-8编码保存了我的文件而没有bom.
RHS*_*ger 109
有问题的字符
是Unicode字符'ZERO WIDTH NO-BREAK SPACE'(U + FEFF).可能是您通过复制/粘贴将其复制到代码中而未实现它.它不可见的事实使得很难判断您是否正在使用显示实际unicode字符的编辑器.
一种选择是在非常基本的文本编辑器中打开文件,该编辑器不了解unicode,或者理解它但能够使用实际代码显示任何非ascii字符的文件.
找到它后,您可以删除它周围的小块文本并手动重新键入该文本.
小智 31
尝试:
<?php
// Tell me the root folder path.
// You can also try this one
// $HOME = $_SERVER["DOCUMENT_ROOT"];
// Or this
// dirname(__FILE__)
$HOME = dirname(__FILE__);
// Is this a Windows host ? If it is, change this line to $WIN = 1;
$WIN = 0;
// That's all I need
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UTF8 BOM FINDER and REMOVER</title>
<style>
body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; background: #FFF; color: #000; }
.FOUND { color: #F30; font-size: 14px; font-weight: bold; }
</style>
</head>
<body>
<?php
$BOMBED = array();
RecursiveFolder($HOME);
echo '<h2>These files had UTF8 BOM, but i cleaned them:</h2><p class="FOUND">';
foreach ($BOMBED as $utf) { echo $utf ."<br />\n"; }
echo '</p>';
// Recursive finder
function RecursiveFolder($sHOME) {
global $BOMBED, $WIN;
$win32 = ($WIN == 1) ? "\\" : "/";
$folder = dir($sHOME);
$foundfolders = array();
while ($file = $folder->read()) {
if($file != "." and $file != "..") {
if(filetype($sHOME . $win32 . $file) == "dir"){
$foundfolders[count($foundfolders)] = $sHOME . $win32 . $file;
} else {
$content = file_get_contents($sHOME . $win32 . $file);
$BOM = SearchBOM($content);
if ($BOM) {
$BOMBED[count($BOMBED)] = $sHOME . $win32 . $file;
// Remove first three chars from the file
$content = substr($content,3);
// Write to file
file_put_contents($sHOME . $win32 . $file, $content);
}
}
}
}
$folder->close();
if(count($foundfolders) > 0) {
foreach ($foundfolders as $folder) {
RecursiveFolder($folder, $win32);
}
}
}
// Searching for BOM in files
function SearchBOM($string) {
if(substr($string,0,3) == pack("CCC",0xef,0xbb,0xbf)) return true;
return false;
}
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
将此代码复制到php文件上传到root并运行它.
有关这方面的更多信息:http://forum.virtuemart.net/index.php?topic = 98700.0
小智 13
"我不知道为什么会这样."
好吧,我刚刚遇到了可能的原因:-)您的HTML页面正在从单独的文件中组装.也许您的文件只包含最终页面的正文或横幅部分.这些文件包含BOM(0xFEFF)标记.然后,作为合并过程的一部分,您将在最终合并的HTML文件上运行HTML tidy或xmllint.
这将导致它!
小智 6
如果您要查看大量文件,可以使用此工具:https: //www.mannaz.at/codebase/utf-byte-order-mark-bom-remover/
致毛里求斯
它帮助我清理一个系统,使用CakePhp中的MVC,因为我在Linux,Windows中使用不同的工具..在某些文件中我的设计是中断..所以在使用调试工具在Chrome中检查后找到错误
归档时间: |
|
查看次数: |
122725 次 |
最近记录: |