In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the difference between jump and redirection in PHP". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the differences between jump and redirection in PHP?"
Difference: 1. The jump is the success of the current URL request, and the new URL; is requested again while the redirection is invalid in the current URL and is relocated to the new URL. 2. During the jump, the browser will record the current URL and the new URL to the history, but the redirection will not. 3. Redirection cannot be reversed to the current URL, while redirection can.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The difference between Jump and Redirection in PHP
Jump:
The browser believes that the current URL request is successful and re-request a new URL.
The browser records the current URL and the new URL in the request history.
Fallback, you can fallback to the current URL. (both success and error are the same)
Syntax implementation: at the browser level, modify the browser's location.href to achieve: location.href=href
Redirect:
The browser believes that the current URL is invalid and has been relocated to the new URL.
The browser will not record the current URL to the history
Cannot fall back to the current URL.
Syntax implementation, where the server sends a redirect response instruction to the browser
Through the response header:
Header ('Location:'. URL), immediately redirect to a URLheader ('Refresh:')
Page redirection must have page jump, page jump does not necessarily have page redirection, that is to say, page redirection is really included in page jump, page redirection is a sufficient and necessary condition for page jump.
Redirect usage instance
Redirect is to redirect all kinds of network requests to other locations through various methods (such as web page redirection, domain name redirection, change of routing is also a kind of redirection of data packets via path).
In the construction of our website, we often encounter situations that require web page redirection:
1. Site adjustment (e. G. changing the directory structure of web pages)
two。 The page was moved to a new address
3. Change the web page extension (for example, the application needs to change .php to .html or .shtml).
In this case, if there is no redirect, the old address in the user's favorites or search engine database can only give the visiting customer a 404 page error message, and the access traffic will be lost in vain; in addition, some websites that have registered multiple domain names also need to redirect users visiting these domain names to the main site automatically.
Summarize several methods of page jump under PHP
1. Meta tag implementation
Just add the following sentence to the head and jump to the target page after staying on the current page for 0 seconds.
Echo''
2. JavaScript implementation
Echo'_ window.location.href = 'https://www.baidu.com';';
3. Implementation of PHP page redirection
Header ('Location: https://www.baidu.com');
Using PHP page redirection jumps is a little different from the above two methods in that its http reply status code is specified as 3xx. The specific differences relate to the request process of HTTP, so I won't go into details here.
Thank you for your reading, the above is the content of "what is the difference between jump and redirection in PHP". After the study of this article, I believe you have a deeper understanding of the difference between jump and redirection in PHP, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.