由Wordpress自动生成的PHP页面中的BOM

时间:2009-11-29 00:29:24

标签: php apache wordpress byte-order-mark

我管理两个不同的博客。它们都是wordpress 2.8.6(因此它们具有完全相同的源代码,插件除外)但它们位于两个不同的托管平台(hostmonster.com和aruba.it)。 为了解释我的问题,我已经使用SmartSniff与每个站点进行会话。

这是来自hostmonster的转储:

GET /blog/paolo/ HTTP/1.1
Host: www.e-venturi.com
Accept-Encoding: identity
Accept-Language: en-us
Accept: text/html, text/plain, text/xml, image/gif, image/x-xbitmap, image/x-icon,image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;)


HTTP/1.1 200 OK
Date: Sat, 28 Nov 2009 23:47:38 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.11
X-Pingback: http://www.e-venturi.com/blog/paolo/xmlrpc.php
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

a6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

现在来自阿鲁巴:

GET /blog/ HTTP/1.1
Host: www.cubanite.net
Accept-Encoding: identity
Accept-Language: en-us
Accept: text/html, text/plain, text/xml, image/gif, image/x-xbitmap, image/x-icon,image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;)


HTTP/1.1 200 OK
Date: Sat, 28 Nov 2009 23:49:19 GMT
Server: Apache/2.2
X-Pingback: http://www.cubanite.net/blog/xmlrpc.php
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

100b
...<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

(注意:a6和100b是SmartSniff报告的数据包大小)

好的,最大的区别是阿鲁巴的<!DOCTYPE前面的三个点。它们是UTF-8 BOM(0xef 0xbb 0xbf)。

在两台服务器上都是相同的PHP源,为什么它只出现在一台服务器上?

内容已生成,因此帖子作者无法故意插入BOM,我也已将模板验证为无BOM。 当然,服务器上有不同的PHP和Apache版本......我可以检查或设置什么来诊断和解决问题?顺便说一下,我不想要BOM。

非常感谢提前。

1 个答案:

答案 0 :(得分:5)

BOM在开放<?php之前位于其中一个PHP源文件中。偶尔会出现这种情况,因为您在编写糟糕的文本编辑器中查看了源代码,使用了带有错误的FTP客户端,使用了自动投入BOM的解压缩工具,从阴影镜像中获取源代码等。

我的解决方案是在Notepad ++中打开主WP文件(index.phpwp-*.php等)并将格式从Windows / Mac切换到Unix并关闭BOM。这将清理任何源问题的文件。

您在两台不同服务器上看到它的原因可能是因为服务器运行两个不同的服务器应用程序或两个不同的操作系统(甚至有两种不同的配置)。平台差异将导致您的服务器发送自己对BOM的唯一解释。

希望这有帮助!