Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Die after redirect #101

Closed
ghost opened this issue May 29, 2013 · 2 comments
Closed

Die after redirect #101

ghost opened this issue May 29, 2013 · 2 comments

Comments

@ghost
Copy link

ghost commented May 29, 2013

Is it intentional that the script won't immediately exit after a redirect()? In fact, it won't even break out of the callback unless I return right after. Seems a little counter-intuitive to me, but might be I'm missing something.

@Rican7
Copy link
Member

Rican7 commented May 29, 2013

Yes. A redirect() call is simply a way to easily set the Response's code and "Location" header. This is much like Ruby's "Rack" middleware, and most other implementations of low-level HTTP handling in frameworks.

The redirect() method also conveniently locks the Response, though, so no further modifications will easily be made to it without explicitly unlocking it first.

If you'd like a more immediate effect, then you could run send() right after to write the headers right then. However, the code following those statements will still run.

It may seem counter-intuitive if you think of the redirect() method as a "browser command" or some other black magic, but all its really doing is sending a header, which PHP has to send to the browser/HTTP client.

Fore more information: http://stackoverflow.com/a/2747803/852382

@Rican7 Rican7 closed this as completed May 29, 2013
@ghost
Copy link
Author

ghost commented May 29, 2013

Thanks for the explanation. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant