header_remove()
function removes the HTTP header previously set by header()
function.
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" ) ; ?>
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 ( ) ; ?>
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.
header_remove ( headername )
parameter | describe |
---|---|
headername |
Optional. Specifies the header name to be deleted. If omitted, delete all previously set headers. |