anonymousdude — 2010-02-01T22:50:47-05:00 — #1
I had the following code at the top of a page thinking that it prevented the rest of the page from executing if the condition was met.
Obviously the simple solution would be to add an else clause such as..
//Execute the rest of the page
Or another option would be,
But I was surprised that the header function waited until the end of the page to work. Is that a configuration thing, or just the norm?
phpycho — 2010-02-01T22:57:22-05:00 — #2
Best would be:
//rest code goes here....
crmalibu — 2010-02-02T01:21:48-05:00 — #3
The header function does nothing more than send an http header. Sending an http header doesn't, and shouldn't, make the script stop executing.
php will send the headers as soon as you send some output(text, html etc..), unless output buffering is enabled. That doesn't mean the browser will immediately read it though. A location header is strictly an advisory to the remote client(browser). The browser doesn't need to obey if it doesn't want to.