No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

headers_sent

(PHP 4, PHP 5, PHP 7)

headers_sentChecks if or where headers have been sent

Description

headers_sent ([ string &$file [, int &$line ]] ) : 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.

PHP: headers_sent - Manual Home of Manuel PHP  Contents Haut

Parameters

file

If 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.

line

The line number where the output started.

PHP: headers_sent - Manual Home of Manuel PHP  Contents Haut

Return Values

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

PHP: headers_sent - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 Examples using headers_sent()

<?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;
}

?>

PHP: headers_sent - Manual Home of Manuel PHP  Contents Haut

Notes

Note:

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

PHP: headers_sent - Manual Home of Manuel PHP  Contents Haut

See Also

  • ob_start() - Turn on output buffering
  • trigger_error() - Generates a user-level error/warning/notice message
  • headers_list() - Returns a list of response headers sent (or ready to send)
  • header() - Send a raw HTTP header for a more detailed discussion of the matters involved.

Find a PHP function
Error Infobrol

Can not display this page of the Infobrol website

Type of error (18-01)

Unknown format specifier "&"

Please try again in a few minutes…

Return to the home page




Steph