WordPress 自动生成的 PHP 页面中的 BOM
我管理两个不同的博客。它们都是 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">
现在是来自 aruba 的转储:(
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 报告的数据包大小)
好的,最大的区别是 前面的三个点在阿鲁巴岛。它们是 UTF-8 BOM (0xef 0xbb 0xbf)。
由于两台服务器上的 PHP 源相同,为什么它只出现在一台服务器上?
内容已生成,因此帖子作者无法故意插入 BOM,并且我也已验证该模板不含 BOM。 当然,服务器上有不同的 PHP 和 Apache 版本...我可以检查或设置什么来诊断和解决问题?顺便说一句,我不想要 BOM。
非常感谢。
I admin two different blogs. They are both wordpress 2.8.6 (so they have exactly the same source code, plugins apart) but they are located on two different hosting platform (hostmonster.com and aruba.it).
To explain my problem I've dumped with SmartSniff a session with each one of the sites.
Here is the dump from 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">
and now from aruba:
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">
(note: a6 and 100b are the packet size reported by SmartSniff)
Ok, the big difference are the three dots in front of the <!DOCTYPE
in aruba. They are the UTF-8 BOM (0xef 0xbb 0xbf).
Being the same PHP source on both the servers, why does it appears only on one server ?
The content is generated so the post author can't deliberately insert a BOM and I've verified the template to be BOM free too.
Naturally there are different PHP and Apache versions on the servers... what can I check or set to diagnose and resolve the problem ? By the way I don't want the BOM.
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
BOM 位于打开
之前的 PHP 源文件之一中。有时,会出现这种情况,因为您在编写很差的文本编辑器中查看了源代码,使用了有错误的 FTP 客户端,使用了自动放入 BOM 的解压缩工具,从阴暗的镜像中获取了源代码等等。
我的解决方案是在 Notepad++ 中打开主 WP 文件(
index.php
、wp-*.php
等),并将格式从 Windows/Mac 切换为 Unix并关闭 BOM。这将清除文件中的所有源问题。您在两台不同服务器上看到不同的原因可能是因为服务器运行两个不同的服务器应用程序或两个不同的操作系统(甚至具有两种不同的配置)。平台差异会导致您的服务器发送自己对 BOM 的独特解释。
希望这有帮助!
The BOM is in one of the PHP source files before the opening
<?php
. Occasionally, this can pop up because you viewed the source in a poorly written text editor, used an FTP client with a bug, used an unzip tool that automatically threw in the BOM, got the source code from a shady mirror, etc. etc.My solution is to open up the primary WP files (
index.php
,wp-*.php
, etc.) in Notepad++ and switch the format from Windows/Mac to Unix and turn off the BOM. This will clean up the files of any source issues.The reason you're seeing it differently on two different servers could be because the servers are running two different server applications or two different operating systems (or even having two different configurations). The platform disparities would lead to your servers sending out their own unique interpretation of the BOM.
Hope this helps!