In a web system, jumping from one Web page to another is one of the most common technologies in the project.
Page jumps may be caused by a user clicking on a link, a button, or a system is automatically generated.
Here is a common way to realize the automatic page jump in PHP.
PHP page Jump One, header () function
The header () function is a very simple way to make a page jump in PHP.
The main function of the header () function is to output HTTP protocol headers (headers) to the browser.
The header () function is defined as follows:
void header (String string [, bool replace [, int http_response_code]])
Optional parameter replace indicates whether to replace the previous similar header or to add a header of the same type, which defaults to replace.
The Second optional parameter Http_response_code forces the HTTP corresponding code to the specified value.
The header of the location type in the header function is a special header invocation that is commonly used to implement page jumps.
Attention:
1.location and ":" No space between, otherwise will not jump.
2. You cannot have any output before using the header.
The PHP code after 3.header will also be executed.
< PHP
redirect Browser
Header ("location:http://www.111cn.net/");
Ensure that subsequent code is not executed after redirection
Exit
?>
PHP page jump two, meta tags
Meta tag is the HTML in charge of providing the document Meta Information label, in the PHP program to use the tag, you can also implement page jump.
If you define HTTP-EQUIV as refresh, the page will be opened to the corresponding page within a certain amount of time according to the value specified by the content.
If set content= "seconds; url= url", then define how long after the page jumps to the designated URL.
< meta http-equiv= "Refresh"
Content= "1;url=http://www.111cn.net/" >
< PHP
$url = "http://www.111cn.net/";?>
< html>
< head>
< meta http-equiv= "Refresh" content= "1;
url=<, PHP echo $url?> ">
< body>
The page stays only one second ...
</body>
PHP page jump three, JavaScript
For example, this code can be placed in any legal position in the program.
<?php
$url = "http://www.111cn.net/";
Echo < script language= ' JavaScript '
Type= ' Text/javascript ' > ';
Echo ' window.location.href= ' $url ';
Echo ' </script> ';
?
above is we introduce to you three kinds of PHP page jump implementation method.