PHP page jump to another page various jump page code _php tutorial

Source: Internet
Author: User
The only way to implement page jumps in PHP is to use the header (location: $go _url); can achieve the page to jump, the following I will give you a detailed introduction of the students.

PHP header () page jump

I took the blog from http://www. Your domain name/blog migrated to http://www.bKjia.c0m domain, when the user visited the previous blog address, automatically jump to the current blog corresponding article

The code is as follows Copy Code

$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 string [, bool replace [, int http_response_code]])
The optional parameter, replace, indicates whether to replace the previous similar header or to add a header of the same type, which is replaced by default.
The Second optional parameter, Http_response_code, forces the HTTP corresponding code to be set to the specified value. The header of the location type in the header function is a special header call that is commonly used to implement page jumps.

Attention:

1.location and ":" Can not have spaces between, otherwise will not jump.
2. There can be no output before using the header.
PHP code after 3.header will also be executed.

There is also a js+php page jump method

JavaScript (common, recommended)

For example, this code can be placed in any legitimate location in the program.

The code is as follows Copy Code

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

1. Code for page jumps in HTML code

HTML Meta Refresh and jump (redirect) page
Refresh property Value--refreshes and jumps (redirect) page
* Refresh for refreshing and jump (redirect) pages
* Refresh appears in the Http-equiv attribute, using the content property to indicate the start time of the 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

5 Seconds to go to the Dream Capital homepage:

The code is as follows Copy Code

Click Submit and then jump

Click the button

Using the Post method

x.php page only after the Judgment logic processing

The code is as follows Copy Code

Isset function
if (Isset ($_post["name"]))
{
Header ("Location:xx.php?name=". $_post["name"]);
}
?>

Note that because the current page already has output content, so the jump transfer in PHP error.

The above page jump code can be implemented between your page and page jump function, and some can be implemented in other environments to achieve page jumps.

http://www.bkjia.com/PHPjc/631533.html www.bkjia.com true http://www.bkjia.com/PHPjc/631533.html techarticle in PHP to implement page jumps only one way, is to use the header (location: $go _url), you can achieve the page jump, I will give you a detailed introduction of the students. PHP hea ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.