CancelImage Upload

How to find out if headers have already been sent in PHP

A lot of programmers struggle to understand the principle behind headers, and how they are supposed to be defined right at the beginning of a page's code. It is no good defining them halfway down the page.

Here then is a function that can serve as a reminder that depending on where they have been defined, the headers might have already been sent. The function in question is:

headers_sent()

If the headers have already been sent this function will return TRUE (or 1), while if 0 you will have gotten there in time.

<?php

if(!headers_sent())
{

     //Define your headers here

}

?>


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com