由 Wordpress 自动生成的 PHP 页面中的 BOM [英] BOM in a PHP page auto generated by Wordpress

查看:21
本文介绍了由 Wordpress 自动生成的 PHP 页面中的 BOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这是来自 hostmonster 的转储:

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">

现在来自阿鲁巴:

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 报告的数据包大小)

(note: a6 and 100b are the packet size reported by SmartSniff)

好的,最大的区别是在aruba中<!DOCTYPE前面的三个点.它们是 UTF-8 BOM (0xef 0xbb 0xbf).

Ok, the big difference are the three dots in front of the <!DOCTYPE in aruba. They are the UTF-8 BOM (0xef 0xbb 0xbf).

在两台服务器上使用相同的PHP源代码,为什么它只出现在一台服务器上?

Being the same PHP source on both the servers, why does it appears only on one server ?

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

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.

非常感谢.

推荐答案

BOM 在打开 <?php 之前的 PHP 源文件之一中.有时,这可能会弹出,因为您在编写不佳的文本编辑器中查看源代码、使用有错误的 FTP 客户端、使用自动放入 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.

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

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.

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

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.

希望这会有所帮助!

这篇关于由 Wordpress 自动生成的 PHP 页面中的 BOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆