headers_sent

PHP 4, PHP 5, PHP 7, PHP 8
headers_sent - Checks if or where headers have been sent
Manual
Code Examples

headers_sent( [stringfilename = null], [intline = null] ): bool

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.

Parameters

filename

If the optional filename and line parameters are set, headers_sent will put the PHP source file name and line number where output started in the filename and line variables.

line

The line number where the output started.

Return Values

headers_sent will return false if no HTTP headers have already been sent or true otherwise.

Notes

Note:

Headers will only be accessible and output when a SAPI that supports them is in use.

Related Functions

Example of headers_sent

Show all examples for headers_sent

PHP Version: