468,270 Members | 1,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,270 developers. It's quick & easy.

Observations regarding redirection

Hello,

I don't know if it is only me but I was sure that header("Location:url")
redirects the browser instantly to URL, or at least stops the execution of
the code. But appearantely it continues to execute the code until the
browser send his reply to the header instruction. So an exit(); after each
redirection won't hurt at all
Jul 16 '05 #1
2 5094
Albert Ahtenberg wrote:
Hello,

I don't know if it is only me but I was sure that header("Location:url")
redirects the browser instantly to URL, or at least stops the execution of
the code. But appearantely it continues to execute the code until the
browser send his reply to the header instruction. So an exit(); after each
redirection won't hurt at all


header('Location:xxx') simply adds the redirection as a header line at
the top of the document. The rest of the script still continues to
execute. Once the browser has loaded the document it reads the header
and goes off to load the redirected page. You will need an exit() after
such a redirection.

Jul 16 '05 #2
..oO(Tyno Gendo)
>yes, i fell into that trap once...

you always need to exit( header('Location: /blah.php') ); to avoid code
after the header being executed.
And you have to use an absolute URL, as required by the HTTP spec.

Micha
Sep 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Gerard M Foley | last post: by
15 posts views Thread by Taki Jeden | last post: by
3 posts views Thread by Chiranjib | last post: by
2 posts views Thread by Nadav | last post: by
8 posts views Thread by Luciano A. Ferrer | last post: by
13 posts views Thread by souissipro | last post: by
1 post views Thread by comp.lang.php | last post: by
13 posts views Thread by Massimo Fabbri | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.