Php page jump to another page various jump page code

Source: Internet
Author: User
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. Phph

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.

Php header () page jump

I pull the blog from the blog:

  1. $ Url_this = strtolower ('http: // '. $ _ SERVER ["SERVER_NAME"]. $ _ SERVER ["REQUEST_URI"]);
  2. $ Go_url = str_replace ('http: // www. phpfensi/blog', 'http: // www.phpfensi.com ', $ url_this );
  3. 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, which is replaced by default.

The second optional parameter http_response_code sets the HTTP code to a 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 put in any valid position in the program. The code is as follows:

  1. $ Url = "http://www.phpfensi.com ";
  2. Echo" ";
  3. Echo "window. location. href = '$ url '";
  4. Echo "script";
  5. ?>

1. page jump code in HTML code

HTML meta refresh and redirect page

Refresh property value-refresh and redirect page

* Refresh is used to refresh and redirect pages.

* Refresh appears in the http-equiv attribute. the content attribute indicates the start time of the refresh or redirect and the URL to jump.

Meta refresh example,Refresh the page 5 seconds later. the code is as follows:

Go to the php fan network homepage in 5 seconds. the code is as follows:

Click submit and then jump. click the button, Using the POST method

The X. php page only uses the judgment logic and jumps after processing. the code is as follows:

  1. // Isset function
  2. If (isset ($ _ POST ["name"])
  3. {
  4. Header ("Location: XX. php? Name = ". $ _ POST [" name "]);
  5. }
  6. ?>

Note: As the current page already has Output Content, an error will be reported during this jump in PHP. the above page jump code can achieve the jump function between your page and the page, some can also achieve page jump in other environments.

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.