使用 PHP5 (cgi) 从文件系统输出模板文件,但在输出原始 HTML 时遇到问题。
private function fetch($name) {
$path = $this->j->config['template_path'] . $name . '.html';
if (!file_exists($path)) {
dbgerror('Could not find the template "' . $name . '" in ' . $path);
}
$f = fopen($path, 'r');
$t = fread($f, filesize($path));
fclose($f);
if (substr($t, 0, 3) == b'\xef\xbb\xbf') {
$t = substr($t, 3);
}
return $t;
}
尽管我已经添加了 BOM 修复,但 Firefox 接受它仍然存在问题。您可以在此处查看实时副本:http://ircb.in/jisti/ http://ircb.in/jisti/(以及我扔给的模板文件http://ircb.in/jisti/home.html http://ircb.in/jisti/home.html如果你想查看的话)
知道如何解决这个问题吗?奥奥
您可以使用以下代码删除 utf8 bom
//Remove UTF8 Bom
function remove_utf8_bom($text)
{
$bom = pack('H*','EFBBBF');
$text = preg_replace("/^$bom/", '', $text);
return $text;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)