PHP page jumps to another page various jump page codes_PHP tutorial

WBOY
Release: 2016-07-13 16:57:23
Original
933 people have browsed it

There is only one way to implement page jump in php, which is to use header(location:$go_url); to achieve page jump, let me introduce it to you in detail below.

php header() page jump

I moved my blog from http://www.yourdomain/blog to http://www.bKjia.c0m. When users visit the previous blog address, they will automatically jump to the corresponding article of the current blog

The code is as follows Copy code
 代码如下 复制代码

$url_this=strtolower('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); 
$go_url=str_replace('http://www.你的域名/blog','http://www.bKjia.c0m',$url_this); 
header("location:$go_url");  exit;

$url_this=strtolower('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);

$go_url=str_replace('http://www.yourdomain name/blog','http://www.bKjia.c0m',$url_this);
header("location:$go_url"); exit;


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 a header of the same type. The default is replace.

The second optional parameter http_response_code forces the HTTP response 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.

There is also a js+php page jump method

JavaScript (commonly used, recommended)
 代码如下 复制代码

< ?php
$url = "http://www.bKjia.c0m";
echo "";
?>

For example, this code can be placed anywhere in the program that is legal.

The code is as follows Copy code
< ?php

$url = "http://www.bKjia.c0m";

echo "";
?>

1. Page jump code in HTML code

HTML meta refresh refresh and jump (redirect) page

refresh attribute value -- refresh and jump (redirect) page
 代码如下 复制代码

* refresh is used to refresh and jump (redirect) pages

* refresh appears in the http-equiv attribute, and uses the content attribute to indicate the start time of refresh or jump and the URL of the jump

 代码如下 复制代码

meta refresh example Refresh this page after 5 seconds:
The code is as follows Copy code
Go to the Dream City homepage in 5 seconds:
The code is as follows Copy code

Click submit and then jump

Click the button

Use POST method

The X.php page only performs judgment logic after processing

The code is as follows
 代码如下 复制代码

//isset函数
if(isset($_POST["name"]))
{
header("Location: XX.php?name=".$_POST["name"]);
}
?>

Copy code

//isset function
if(isset($_POST["name"]))
{
header("Location: XX.php?name=".$_POST["name"]);
}
?>

Note that since the current page already has output content, such a jump will cause an error in PHP.

The above page jump codes can all realize the function of jumping between your pages, and some can also realize page jumps in other environments. http://www.bkjia.com/PHPjc/631533.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/631533.html
TechArticle
There is only one way to implement page jump in php, which is to use header(location:$go_url); The page jump can be realized. Now I will give you a detailed introduction. php hea...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template