0

在 Apache 配置中,可以设置以下指令以使 httpd 始终为 text/html 和 text/plain MIME 类型发送 UTF-8 字符编码标头:

AddDefaultCharset utf-8

我希望能够在我的 PHP 脚本中检测是否正在发送此标头,以便header()如果尚未发送,我可以使用该函数发送相同的标头。

我怎样才能检测到这个?

4

2 回答 2

2

There's apache_response_headers(), though it'll only report on headers that are already "in play". If your charset header is added after the fact, you'd never see it.

于 2012-09-24T14:29:40.550 回答
0

deceze在对最初问题的评论中提供的信息否定了答案的必要性。但是,为了完整起见,我想说似乎没有一种明显的方法来检测 Apache 是否从 PHP 中发送了标头...但是,鉴于上述信息,我想不出你需要这样做的一个原因。

于 2012-10-05T12:38:20.057 回答