Current Location: Home> Function Categories> header_remove

header_remove

Delete the HTTP header that was set before
Name:header_remove
Category:Network
Programming Language:php
One-line Description:Removes the HTTP header set previously using the header() function.

Definition and usage

header_remove() function removes the HTTP header previously set by header() function.

Example

Example 1

Delete a specific header:

 <?php
header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ) ;
header ( "Cache-Control: no-cache" ) ;
header ( "Pragma: no-cache" ) ;

header_remove ( "Pragma" ) ;
?>

Example 2

Delete all previously set headers:

 <?php
header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ) ;
header ( "Cache-Control: no-cache" ) ;
header ( "Pragma: no-cache" ) ;

header_remove ( ) ;
?>

Example explanation:

In this example, all HTTP headers ( "Expires" , "Cache-Control" , and "Pragma" ) that were previously set by header() function will be removed by calling header_remove() function (without parameters). This means that the HTTP response will not contain these header information. This can be useful in some cases, especially if you want to reset or clear the header information that was previously set. However, note that header_remove() function does not affect the header that PHP has sent to the client; it only affects headers that are still pending when the function is called.

grammar

 header_remove ( headername )

Parameter value

parameter describe
headername

Optional. Specifies the header name to be deleted.

If omitted, delete all previously set headers.

Similar Functions
Popular Articles