What is the difference between redirect and forward in Zend framework?
When we should use redirect and when should we use forward?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
_forward()just forwards everything to another controller action, while_redirect()sends a header, meaning you create a new HTTP Request and go through the entire dispatch process with it.For instance, if you call up http://example.com/foo/bar you’d call the
foocontroller andbaraction. If you forward inside thebaraction to thebazaction, e.g. within the very same request, the browser would still be on the same URL, while when doing a redirect, ZF would instruct the browser to load http://example.com/foo/baz.Essentially,
_forward()doeswhile
_redirect()doesI usually do redirects when I want to prevent reload a page resulting in reposting form data.
See these: