如何修复php-export-data类的标题错误?

时间:2016-09-02 07:36:41

标签: php header export-to-excel

我使用php-export-data类来获得excel输出。这个类适用于我的localhost和godady服务器,但在我的新服务器上不起作用。

它给出了标题错误。喜欢这个。:

Warning: Cannot modify header information - headers already sent by (output started at /home/mmm/public_html/head/adminsss/config.php:1) in /home/mmm/public_html/head/adminss/modules/head/class/php-export-data.class.php on line 489    
 Warning: Cannot modify header information - headers already sent by (output started at /home/mmm/public_html/head/adminsss/config.php:1) in /home/mmm/public_html/head/adminsss/modules/head/class/php-export-data.class.php on line 490<br>
Line 489 => header("Content-Type: application/vnd.ms-excel; charset=" . $this->encoding); 
Line 490 => header("Content-Disposition: inline; filename=\"" . basename($this->filename) . "\"");
  • localhost PHP Version 5.5.11
  • godady PHP Version 5.3.24
  • 新服务器PHP版本5.5.23

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

如果错误消息显示第一行,如“/config.php:1”,则必须将php文件转换为无BOM。

UTF-8 BOM

单独的换行符和空格可能是个问题。但也有“隐形”字符序列可以导致这种情况。最着名的是大多数文本编辑器都没有显示的UTF-8 BOM(字节顺序标记)。这是字节序列EF BB BF,对于UTF-8编码文档是可选的和冗余的。然而,PHP必须将其视为原始输出。它可能会在输出中显示为字符(如果客户端将文档解释为Latin-1)或类似的“垃圾”。