Killrawr Killrawr - 10 months ago 68
PHP Question

Clear previously set headers php

I would like to know if its possible to clear the current information stored in header_list()

foreach(headers_list() as $header){

Answer Source

headers_sent indicates that it is too late to remove headers. They're already sent. Hence the name of the function.

What you want is to specifically check if the headers have not been sent yet. Then you know it's safe to modify them.

if (!headers_sent()) {
  foreach (headers_list() as $header)