Warning: Cannot modify header information - headers already

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Warning: Cannot modify header information - headers already

Post by hannnndy »

hi friends

please help i seriously face this problem again

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\

please help

Code: Select all

 
ob_start();
    echo('test');
    header('Location: http://www.google.com');
ob_end_clean();
 
the test even not printed i do not know what to do
User avatar
webspider
Forum Commoner
Posts: 52
Joined: Sat Oct 27, 2007 3:29 am

Re: Warning: Cannot modify header information - headers already

Post by webspider »

header() must be called before any output is sent. check any html output is sent to browser before calling header.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Warning: Cannot modify header information - headers already

Post by Chris Corbyn »

webspider wrote:header() must be called before any output is sent. check any html output is sent to browser before calling header.
Read up on ob_start() and friends ;)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Warning: Cannot modify header information - headers already

Post by Chris Corbyn »

Test won't be printed because you're using ob_end_clean() instead of ob_flush() or "echo ob_getClean();". That code alone shouldn't be giving you headers already sent errors though. Unless you have some whitespace before the <?php tag.
User avatar
webspider
Forum Commoner
Posts: 52
Joined: Sat Oct 27, 2007 3:29 am

Re: Warning: Cannot modify header information - headers already

Post by webspider »

Read up on ob_start() and friends ;)
really........ :oops:
Post Reply