【问题标题】:BOM in a PHP page auto generated by Wordpress由 Wordpress 自动生成的 PHP 页面中的 BOM
【发布时间】:2010-12-21 07:38:44
【问题描述】:

我管理两个不同的博客。它们都是 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 报告的数据包大小)

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

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

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

非常感谢。

【问题讨论】:

  • 您确定检查了所有文件的 BOM 吗? IE。不仅是请求的,还有所有包含的。
  • chelmertz,你是对的 :-( 我忘记了一个小文件,它有一个 BOM ......它在一个插件中。我必须通过 ftp 下载整个博客并检查每个文件我在运行中完成的一个小程序(我不能在阿鲁巴的服务器上执行此操作)并且我找到了它。感谢让我再次检查所有内容;-)

标签: php apache wordpress byte-order-mark


【解决方案1】:

BOM 位于打开 &lt;?php 之前的 PHP 源文件之一中。有时,这可能会弹出,因为您在编写不佳的文本编辑器中查看了源代码,使用了有错误的 FTP 客户端,使用了自动放入 BOM 的解压缩工具,从阴暗的镜子中获取源代码等等。

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

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

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2012-12-14
    • 2015-12-25
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 2018-07-28
    • 2022-08-15
    • 1970-01-01
    相关资源
    最近更新 更多