PHP Function Reference

PHP header_remove() Function



The PHP header_remove() function is used to remove an HTTP header previously set using header().

Syntax

header_remove(name)

Parameters

name Optional. Specify the header name to be removed. When null, all previously set headers are removed. Please note that this is a case-insensitive parameter.

Return Value

No value is returned.

Example: removing specific header

In the example below the header_remove() function is used to remove specific header.

<?php
header("Expires: Mon, 14 Oct 2019 10:30:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");

//removing "Pragma" header
header_remove("Pragma"); 
?>

The output of the above code will be similar to:

Expires: Mon, 14 Oct 2019 10:30:00 GMT
Cache-Control: no-cache

Example: removing all previously set headers

Consider one more example where this function is used to remove all previously set headers.

<?php
header("Expires: Mon, 14 Oct 2019 10:30:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");

//removing all headers
header_remove(); 
?>

The output of the above code will be:



❮ PHP Network Reference