This article is a detailed analysis and introduction to several implementation methods of PHP jump pages. Friends who need it can refer to
Recommended Manual: php completely self-study Manual
● PHP page jump 1. header() function
The header() function is for page jump in PHP A very simple method.
The main function of the header() function is to output the HTTP protocol header (header) to the browser.
The header() function is defined as follows:
void header (string string [,bool replace [,int http_response_code]])
The optional parameter replace specifies whether to replace the previous similar header or add one of the same type header, which defaults to replacement.
The second optional parameter http_response_code forces the HTTP corresponding code to the specified value.
The Location type header in the header function is a special header call, often used to implement page jumps.
Note:
1. There cannot be a space between location and ":" , otherwise it will not jump.
2. There cannot be any output before using the header.
3.The PHP code after the header will also be executed.
For example, redirect the browser to the php Chinese website
The code is as follows:
< ?php //重定向浏览器 header("Location: //m.sbmmt.com/"); //确保重定向后,后续代码不会被执行 exit; ?>
● PHP page jump 2. Meta tag
Meta tag is a tag in HTML that is responsible for providing document meta-information. Using this tag in a PHP program can also achieve page jumps.
If http-equiv is defined as refresh, when the page is opened, it will jump to the corresponding page within a certain period of time based on the value specified by the content.
If content="seconds;url=website" is set, it defines how long it will take for the page to jump to the specified URL.
For example, use the meta tag to automatically jump to the PHP Chinese website after one second.
The code is as follows:
For example, the following program meta.php implements the page to automatically jump to m.sbmmt.com after staying on the page for one second.
The code is as follows:
● PHP page jump three, JavaScript
For example, this code can anywhere legal in the program.
The code is as follows:
< ?php $ url = "//m.sbmmt.com/" ; echo " < script language = 'javascript' type = 'text/javascript' > "; echo " window.location.href = '$url' "; echo " < /script > "; ?>
Recommended related articles:
1. Multiple methods of page jump in PHP
2. How to implement the page jump function in PHP? (Example of function tags)
Related video recommendations:
1. Dugu Jiujian(4)_PHP video tutorial
The above are the three PHP page jump implementation methods we introduced to you.
The above is the detailed content of Several implementation methods of PHP jump page. For more information, please follow other related articles on the PHP Chinese website!