PHP seek page jump-common method: php seek page jump _ PHP Tutorial

Source: Internet
Author: User
Tags php redirect
PHP seek page jump-common method: php seek page jump. PHP seek page jump-common method: php seek page jump PHP page Jump 1. the header () function is a very simple method for page jump in PHP. Main PHP redirect page jump of the header () function-common methods: php redirect page jump

PHP page Jump 1. header () function

The header () function is a very simple method for page jump in PHP. The main function of the header () function is to output the HTTP 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 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. there cannot be spaces between location and:. otherwise, no jump will be made.

2. there cannot be any output before using the header.

3. the PHP code after the header will also be executed. For example, redirect a browser to a Guanwei blog

<? Php
// Redirect the browser
Header ("Location: http://www.guanwei.org ");
// Ensure that subsequent code will not be executed after redirection
Exit;
?>

PHP page jump 2. Meta tag

Meta tag is the tag that provides document Meta information in HTML. you can use this tag in a PHP program to redirect pages. If http-equiv is defined as refresh, the page will be redirected to the corresponding page within a certain period of time based on the value specified by content.

If you set content = "seconds; url = url", it defines how long the page will jump to the specified url. For example, after the meta tag is used to implement the vaccine, the page automatically jumps to the Guanwei blog.

< meta http-equiv="refresh" content="1;url=http://www.guanwei.org">

For example, the following meta. php program will automatically jump to www.guanwei.org after one second in the page.

<? Php
$ Url = "http://www.guanwei.org";?>
<Html>
<Head>
<Meta http-equiv = "refresh" content = "1; url = <? Php echo $ url;?> ">
</Head>
<Body>
The page stays for only one second ......
</Body>
</Html>

PHP page jump 3. JavaScript (common and recommended)

For example, this code can be placed in any legal position in the program.

<? Php
$ Url = "http://www.guanwei.org ";
Echo"

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.