header_remove
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
Remove previously set headers
Description
Removes an HTTP header previously set using header().
Parameters
nameThe header name to be removed. When null, all previously set headers are removed.
NoteThis parameter is case-insensitive.
Return Values
Void
Changelog
| Version | Description |
|---|---|
| 8.0.0 | name is nullable now. |
Examples
Unsetting specific header.
<?php
header("X-Foo: Bar");
header("X-Bar: Baz");
header_remove("X-Foo");
?>The above example will output something similar to:
X-Bar: BazUnsetting all previously set headers.
<?php
header("X-Foo: Bar");
header("X-Bar: Baz");
header_remove();
?>The above example will output something similar to:
Notes
This function will remove all headers set by PHP, including cookies, session and the X-Powered-By headers.
Sapi