php中的utf-8 bom和标题

问题描述:


可能重复:

警告:标题已经在PHP中发送

当我使用utf-8 bom创建我的php文件时,header()函数不起作用,因为bom字符在http标头之前发送。

When I create my php files with utf-8 bom, the header() function doesn't work because the bom chars are sent before the http headers.


  • 这是否意味着我们不应该在php源文件中使用bom?

  • 这是一个功能还是错误?

  • 和使用utf-8编码的php源文件时有什么建议吗?


  • 物料清单在UTF-8中无用。

  • 它们都不是。 PHP正在按预期工作。您的文件由此组成,并且PHP按预期工作,因为它首先在开始<?php 标记之前输出所有数据:

    • The BOM is useless in UTF-8.
    • It's neither. PHP is working as intended. Your file consists of this, and PHP is working as intended, because it outputs all data before the opening <?php tag first:
    • -

<byte order mark><?php // code here

-


  • 不要使用BOM。