header_remove()
header_remove() — Remove previously set headers.
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.3.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Removes an HTTP header previously set using header().
Signature
header_remove(?string $name = null): void
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $name | ?string | The header name to be removed. When null, all previously set headers are removed. |
Return value
No value is returned.
Example
A runnable snippet:
header("X-Foo: Bar"); header("X-Bar: Baz"); header_remove("X-Foo");
Output:
X-Bar: Baz
Changelog
| Version | Change |
|---|---|
| 8.0.0 | name is nullable now. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page header_remove() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.