Php page jump to another page various jump page code. In php, there is only one method for page jump, that is, using the header (location: $ go_url); to achieve page jump, I will give you a detailed introduction. There is only one method for implementing page jump in php in phphea, that is, using header (location: $ go_url); to achieve page jump, next I will introduce you in detail.
Php header () page jump
I migrate the blog from http: // www. your domain name/blog to the http://www.bKjia. c0m domain name, when the user visits the previous blog address, automatically jump to the corresponding article of the current blog
The code is as follows: |
|
$ Url_this = strtolower ('http: // '. $ _ SERVER ["SERVER_NAME"]. $ _ SERVER ["REQUEST_URI"]); $ Go_url = str_replace ('http: // www. your domain name/blog ', 'http: // www. bKjia. c0m', $ url_this ); Header ("location: $ go_url"); exit; |
The header () function is defined as follows:
Void header (string [, bool replace [, int http_response_code])
The optional parameter replace indicates whether to replace the previous header or add a header of the same type. the default parameter is replace.
The second optional parameter http_response_code sets the HTTP code as the specified value. The Location header in the header function is a special header call, which is often used to redirect pages.
Note:
1. no space is allowed between location and:; otherwise, no jump is made.
2. there cannot be any output before using the header.
3. the PHP code after the header will also be executed.
There is also a js + php page jump method
JavaScript (common and recommended)
For example, this code can be placed in any legal position in the program.
The code is as follows: |
|
<? Php $ Url = "http://www.bKjia. c0m "; Echo" |