PHP.nl

headers_sent

headers_sent

Checks if or where headers have been sent

bool **headers_sent** string $filename int $line

Checks if or where headers have been sent.

You can't add any more header lines using the 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 . headerOutput Buffering

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

Opmerking: > If the output has started before executing the PHP source file (for example due to a startup error), the parameter will be set to an empty string. filename

lineThe line number where the output started.

will return false if no HTTP headers

have already been sent or true otherwise. headers_sent

**Voorbeeld: Examples using **

<?php

// If no headers are sent, send one
if (!headers_sent()) {
    header('Location: http://www.example.com/');
    exit;
}

// An example using the optional file and line parameters
// Note that $filename and $linenum are passed in for later use.
// Do not assign them values beforehand.
if (!headers_sent($filename, $linenum)) {
    header('Location: http://www.example.com/');
    exit;

// You would most likely trigger an error here.
} else {

    echo "Headers already sent in $filename on line $linenum\n" .
          "Cannot redirect, for now please click this <a " .
          "href=\"http://www.example.com\">link</a> instead\n";
    exit;
}

?>

ob_start``trigger_error``headers_list``header