PHP headers_sent() Function

The headers_sent() function checks if / where the HTTP headers have been sent.

bool headers_sent ([ string &$file [, int &$line ]] )

Checks if or where headers have been sent.

You can't add any more header lines using the header() function once the header block has already been sent. Using this function you can at least prevent getting HTTP header related error messages. Another option is to use Output Buffering.

Example -

ParameterDescription
fileIf the optional file and line parameters are set, headers_sent() will put the PHP source file name and line number where output started in the file and line variables
lineThe line number where the output started

The headers_sent() will return FALSE if no HTTP headers have already been sent or TRUE otherwise.