Page 1 of 1

Does code execute after header (); ?

Posted: Fri Apr 09, 2004 11:49 pm
by Chris Corbyn
Hi,

I've got a download page which redirects to files based on the input in a form.

Redirect uses the header function but I also wish to fwrite to a log file from this same page. Will the fwrite function be carried out even after redirect has occurred?

Thanks

Posted: Sat Apr 10, 2004 12:02 am
by phice
Why don't you try it? ;)

Posted: Sat Apr 10, 2004 12:15 am
by Chris Corbyn
I was trying it for ages and I couldn't get it to work so I thought I'd post in here to see if it was a lost cause but I've got it working now anyway so i guess the answer is "Yes", code after the header will be executed but not before the header.

Thanks anyway :-)

Posted: Sat Apr 10, 2004 12:16 am
by Chris Corbyn
sorry, that's wrong. Code before the header will be executed too so long as it's not echo or print

Posted: Sat Apr 10, 2004 1:41 am
by timvw
It will also work when they there is output (echo or print).
But this will make the header function fail (because headers have to be outputted before anything else gets outputted). In case you are using output buffering, you could work around that "problem"