Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

headers sent function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php headers sent () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 3>= 3.0.8, PHP 4 , PHP 5)

headers_sent -- Checks if or where headers have been sent

Syntax

bool headers_sent ( [string &file [, int &line]] )

headers_sent() will return FALSE if no HTTP headers have already been sent or TRUE otherwise. 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.

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.

Note: The optional file and line parameters where added in PHP 4.3.0.

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, as of PHP 4.3.0
// 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;
}

?>

See also ob_start(), trigger_error(), and header() for a more detailed discussion of the matters involved.

Php headers sent Function syntax tag

headers sent php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php headers sent syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online