(PHP 5 >= 5.3.0)
header_remove — Remove previously set headers
Removes an HTTP header previously set using header().
The header name to be removed.
Hinweis: This parameter is case-insensitive.
Es wird kein Wert zurückgegeben.
Beispiel #1 Unsetting specific header.
<?php
header("X-Foo: Bar");
header("X-Bar: Baz");
header_remove("X-Foo");
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
X-Bar: Baz
Beispiel #2 Unsetting all previously set headers.
<?php
header("X-Foo: Bar");
header("X-Bar: Baz");
header_remove();
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
This function will remove all headers set by PHP, including cookies, session and the X-Powered-By headers.
This function will remove the first header entry, in the case of multiple headers of the same type have been set.
<?php
header('X-Foo: value1', false);
header('X-Foo: value2', false);
header_remove('X-Foo');
print_r(headers_list());
?>
Gives the response:
Array
(
[0] => X-Foo: value2
)
FYI: This function does not support an array or multiple entries
header_remove(array("X-Powered-By","Expires")); // doesn't work
header_remove("X-Powered-By","Expires"); // doesn't work
Spent the time verifying if it was similar to the unset() command which allows.
unset($a,$b);