What is the difference between redirect and forward in php

WBOY
Release: 2023-03-15 09:58:02
Original
2304 people have browsed it

The difference between redirect and forward in php: 1. The forward forwarding page can share the data in the request, but the redirect forwarding page cannot share data; 2. Forward is generally used to forward to the corresponding module when the user logs in, while redirect is generally used Applies when the user logs out.

What is the difference between redirect and forward in php

The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

What is the difference between redirect and forward in php

1. From the address bar display,

forward is when the server requests resources. The server directly accesses the URL of the target address, reads the response content of that URL, and then Send this content to the browser. The browser has no idea where the content sent by the server comes from, so its address bar is still the original address.

redirect means that the server sends a status code based on logic. , tell the browser to request that address again. So the address bar displays the new URL.

2. From the perspective of data sharing

forward: forward the page and The page forwarded to can share the data in the request.

redirect: cannot share data.

3. From the perspective of application

forward: Generally used when users log in, forwarded to the corresponding module according to the role.

redirect: Generally used when users log out and log in, return to the main page and jump to other websites, etc.

4. In terms of efficiency

forward: high.

redirect: low.

5. If you want to access web pages on different servers , you can only use redirect.

Related recommendations:bootstrap tutorial

The above is the detailed content of What is the difference between redirect and forward in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!