problem with header()

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
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

problem with header()

Post by itsmani1 »

see this code....

Code: Select all

echo "I am here...";
header("Location:index.php?log=true");
exit;
it gives me an error something like "Header already sent.."

i want to use echo "I am here ...." before header();
can i do so?


Thanx.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Re: problem with header()

Post by anjanesh »

itsmani1 wrote: i want to use echo "I am here ...." before header();
can i do so?
I guess its impossible.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: problem with header()

Post by Roja »

itsmani1 wrote: i want to use echo "I am here ...." before header();
can i do so?
Yes. Use output buffering.

http://us3.php.net/manual/en/function.ob-start.php
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

If this is for testing, you can also write the "i'm here" into a file..

Or if you use a debugger, you should be able to step untill before the header call..
Post Reply