RequestDispatcher basically dispatches a request to some other resource i.e it doesn’t do a redirect but simply forwards the page to some page(resource). Thus browser’s history etc is not updated and the parameters that are available in request are still available on another page since we are not creating a new request using redirect.
What is equivalent of this in PHP? And also which function is used to redirect a page?
Thanks in advance 🙂
There’s no direct equivalent.
includeand family are similar, but differ in several aspects:Probably the most similar thing is an internal Apache subrequest (see
virtual), but that has nothing to do with PHP itself. When PHP is invoked, the request has already been “dispatched”. Of course, you can, if you want, do a virtual “request dispatch logic” with PHP, which means sending all the requests to some initial script that then decides what to include/execute. This is what several frameworks do.To redirect a page, you manually send a header: