headers_sent

int headers_sent(void) 

Checks whether HTTP headers have been sent.

Returns:

TRUE if headers have been sent; FALSE if not

Description:

Checks whether HTTP headers have been sent by the server to the client and returns TRUE if they have.

Version:

Existing since version 3.0.8

Example:

Check whether headers have been sent
if (headers_sent()) {
    echo "Headers Sent!"; 
} else {
    Header("Location: http://www.newriders.com/"); 
} 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.