In PHP, header_remove() deletes a previously queued response header by name. If you omit the name, it removes all headers that PHP still controls for the response.
Call it before headers are sent. It is useful when a framework or earlier code set a header you do not want, such as a temporary debug header.
Syntax
Call header_remove() with the values you need. Start with this line.
PHP
header_remove("X-Powered-By");
Call
What it does
header_remove("X-Debug")
Removes the X-Debug header if it was queued.
header_remove("Content-Type")
Clears the Content-Type header so you can set a new one.
header_remove()
Removes all removable response headers.
Pass the header name without a colon. Matching is case-insensitive for the header name. Once headers_sent() is true, removal no longer affects what the client already received.
Library declarations
PHP
header_remove(?string $name = null): void
Parameters
Parameter
Description
name
Optional. The header name to remove, such as "X-Powered-By". Omit it to remove all removable headers.
Return Value
Return Value
Description
void
No return value.
PHP Examples
Example 1 — Remove One Queued Header
Set two headers, remove one, then show what remains in an illustrative headers_list() style listing.