PHP headers_sent() Function
Complete PHP HTTP Reference
Definition and Usage
The headers_sent() function checks if / where the HTTP headers have been sent.
This function returns TRUE if headers has been sent or FALSE if not.
Syntax
| Parameter |
Description |
| file,line |
Optional. If the 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 |
Tips and Notes
Note: You can't add more header lines using header() once the header
block has already been sent.
Note: The optional file and line parameters where added in PHP 4.3.
Example 1
<?php
// If no headers are sent, send one
if (!headers_sent())
{
header("Location: http://www.w3schools.com/");
exit;
}
?>
<html>
<body>
...
...
|
Example 2
Using the optional file and line parameters:
<?php
// $file and $line are passed in for later use
// Do not assign them values beforehand
if (!headers_sent($file, $line))
{
header("Location: http://www.w3schools.com/");
exit;
// Trigger an error here
}
else
{
echo "Headers sent in $file on line $line";
exit;
}
?>
<html>
<body>
...
...
|
Complete PHP HTTP Reference
 |
 |
 |
 |
|
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |
 |
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |
 |
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Utilize the extensive out-of-the box features or customize your site through Ektron CMS400.NET's open architecture |
 |
Promote collaboration in your organization through project workspaces where others can efficiently find information and work together |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
|
|
 |
TAKE THE VIDEO TOUR |
 |
or download a FREE TRIAL today. |
|