Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP headers_sent() Function

PHP headers_sent() Function


PHP HTTP Reference Manual Complete PHP HTTP Reference Manual


Definition and Usage

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

Returns TRUE if the headers have been sent, FALSE otherwise.

Syntax

headers_sent(file,line)

Parameters Description
file,line Optional. If the file and line parameters are set, headers_sent() stores the PHP source file name and line number where output began into the file and line variables.

Tips and Notes

**Note:** Once the header block has been sent, you cannot use header() to send any more headers.

**Note:** The optional file and line parameters were added in PHP 4.3.


Example 1

...

...


Example 2

Using the optional file and line parameters:

...

...


PHP HTTP Reference Manual Complete PHP HTTP Reference Manual