Summary of page jump methods in php development. Summary of page jump methods in php development the function of PHP page jump is to redirect one webpage to another. For friends who have just learned the PHP language, it is necessary to summarize the page jump methods in php development.
The PHP page jump function is to redirect one webpage to another. For friends who have just learned the PHP language, it is a basic method that must be mastered.
Page jump may be triggered by clicking links or buttons, or automatically generated by the system. Automatic page jump is often used in WEB development, and different jump methods can be used as needed, such as delayed jump after prompting operation information, this article summarizes several common page jump methods in WEB development.
PHP header () function jump
PHP's header () function is very powerful. it also makes simple calls in page url jump. you can use header () to directly jump to the specified url page. in this case, the page jump is 302 redirection:
?
1 2 3 |
$ Url = "http://www.jb51.net /"; Header ("Location: $ url "); |
We may encounter special jumps. for example, if the website has a page address for 301 redirection, you can configure rewrite on the web, but now I want to tell you, you can use the php header () function to perform 301 Redirection. the code is as follows:
?
1 2 3 |
// Jump to 301 Header ("HTTP/1.1 301 Moved Permanently "); Header ("Location: $ url "); |
Meta settings jump
In the meta information in html, you can directly set the jump, and set the jump delay time and jump url, which are frequently applied. for example, after the payment is complete, the code is very simple to tell the user that the payment is successful and jump to the order page, add the following sentence:
?
The code above indicates that the page automatically jumps to the http://www.jb51.net after 5 seconds.
Javascript jump
Javascript jump is also very simple, just one sentence:
?
1 2 3 |
Script Window. location. href = "http://www.jb51.net "; Script |
Note: After the above code is directly redirected, you cannot obtain a referer (also called a source) in the target page address. in the actual project, when a customer asks for a jump to bring the path (that is, the target webpage can get where the page is redirected), we can use javascript to simulate a click, then the jump satisfies the customer's needs.
?
1 2 3 4 5 6 7 8 |
Script // There are routes Var aa = document. createElement (""); Aa. setAttribute ("href", "http://www.jb51.net "); Var bodys = document. getElementsByTagName ("body") [0]; Bodys. appendChild (aa ); Aa. click (); Script |
Of course, in actual development, we can integrate the following two methods into PHP to facilitate various jump needs.
The above is all the content of this article. I hope you will like it.
The function of redirect PHP page jump is to redirect a webpage to another webpage. For friends who have just learned the PHP language, it is necessary...