如何通过PHP清除已发送的HTTP头?

2026-04-06 08:561阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计412个文字,预计阅读时间需要2分钟。

如何通过PHP清除已发送的HTTP头?

在PHP中,你可以使用`header_remove`函数清除HTTP头。这个函数的语法是`header_remove([string $name='']) : void`。它将删除之前使用`header`函数设置的任何头信息。

在Windows 7系统、PHP 7.1版本和DELL G3电脑上,清除HTTP头的方法如下:

phpheader_remove('Content-Type');header_remove('X-Powered-By');// 添加更多要清除的头信息...

这样,之前通过`header`函数设置的这些HTTP头信息将被清除。

在php中可以通过header_remove函数清除http头,其语法是“header_remove ([ string $name ] ) : void”,表示删除之前用header()设置的HTTP头。

本文操作环境:windows7系统、PHP7.1版,DELL G3电脑

php怎么清除http头?

header_remove

(PHP 5 >= 5.3.0, PHP 7)

header_remove — 删除之前设置的 HTTP 头

说明

header_remove ([ string $name ] ) : void

删除之前用 header() 设置的 HTTP 头。

参数

name

要移除的头名称。

Note: 参数不分大小写。

返回值

没有返回值。

范例

Example #1 取消指定的头

<?php header("X-Foo: Bar"); header("X-Bar: Baz"); header_remove("X-Foo"); ?>

以上例程的输出类似于:

X-Bar: Baz

Example #2 取消之前全部指定的头

如何通过PHP清除已发送的HTTP头?

<?php header("X-Foo: Bar"); header("X-Bar: Baz"); header_remove(); ?>

注:

Caution

本函数会删除所有 PHP 设置的头, 包括 Cookie、Session 和 X-Powered-By。

Note:

数据头只会在SAPI支持时得到处理和输出。

推荐学习:《PHP视频教程》

以上就是php怎么清除http头的详细内容,更多请关注自由互联其它相关文章!

本文共计412个文字,预计阅读时间需要2分钟。

如何通过PHP清除已发送的HTTP头?

在PHP中,你可以使用`header_remove`函数清除HTTP头。这个函数的语法是`header_remove([string $name='']) : void`。它将删除之前使用`header`函数设置的任何头信息。

在Windows 7系统、PHP 7.1版本和DELL G3电脑上,清除HTTP头的方法如下:

phpheader_remove('Content-Type');header_remove('X-Powered-By');// 添加更多要清除的头信息...

这样,之前通过`header`函数设置的这些HTTP头信息将被清除。

在php中可以通过header_remove函数清除http头,其语法是“header_remove ([ string $name ] ) : void”,表示删除之前用header()设置的HTTP头。

本文操作环境:windows7系统、PHP7.1版,DELL G3电脑

php怎么清除http头?

header_remove

(PHP 5 >= 5.3.0, PHP 7)

header_remove — 删除之前设置的 HTTP 头

说明

header_remove ([ string $name ] ) : void

删除之前用 header() 设置的 HTTP 头。

参数

name

要移除的头名称。

Note: 参数不分大小写。

返回值

没有返回值。

范例

Example #1 取消指定的头

<?php header("X-Foo: Bar"); header("X-Bar: Baz"); header_remove("X-Foo"); ?>

以上例程的输出类似于:

X-Bar: Baz

Example #2 取消之前全部指定的头

如何通过PHP清除已发送的HTTP头?

<?php header("X-Foo: Bar"); header("X-Bar: Baz"); header_remove(); ?>

注:

Caution

本函数会删除所有 PHP 设置的头, 包括 Cookie、Session 和 X-Powered-By。

Note:

数据头只会在SAPI支持时得到处理和输出。

推荐学习:《PHP视频教程》

以上就是php怎么清除http头的详细内容,更多请关注自由互联其它相关文章!