php中的utf-8 bom和标题 [英] utf-8 bom and headers in php

查看:150
本文介绍了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。

      这篇关于php中的utf-8 bom和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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