Friday, December 26, 2008

What is Cannot modify header information in php

Warning: Cannot modify header information - headers already sent by ......
This error is a shocker for a new php programmer. when you do some basic redirection and you bump into this error you are left clueless.

In the simplest form this happens when you output somthing into the screen before using the header() function.


echo 'hello and I doomed the header';

header("Location: login.php");


above code will get that error because you have already output something to the screen.(If you are testing in your local machine this error is not shown)

This error is also generated by a unsuspecting white space. This could be a white space from a include file before the header() function.

Get custom programming done at!

No comments:

Post a Comment