PHP is used by many programmers to develop the web's preferred language. In the actual development, the site's various functions can be written through the PHP language to meet, such as PHP page jump this method.
In a web system, jumping from one Web page to another is one of the most commonly used techniques in the lamp 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. Note: 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. For example, redirect the browser to www.***.com
<?php
Header ("location:http://www.***.com"); REDIRECT Browser
//Ensure that subsequent code is not executed after the redirection
;
? >
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. For example, using a meta tag to implement a vaccine, the page automatically jumps to www.***.com.
<meta http-equiv= "Refresh" content= "1;url=http://www.***.com" >
For example, the following program meta.php realizes that the page automatically jumps to www.***.com after one second of the page is paused.
<?php $url = "http://www.***.com";?>
PHP page jump three, JavaScript
For example, this code can be placed in any legal position in the program.
<?php
$url = "http://www.***.com";
echo "< script language= ' javascript ' type= ' text/javascript ' >";
echo "window.location.href= ' $url '";
echo "</script>";
? >
The above is we introduced to you three kinds of PHP page jump implementation methods.