Php page jump and timed page jump

Source: Internet
Author: User

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 [, 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.


1. Jump using the head function in php


Note: do not have any output before the head jump, or you may not be able to jump.

The code is as follows: Copy code

Header ("refresh: 3; url = http://www.111cn.net"); // time-limited jump
Header ('Location: http://www.111cn.net '); // jump now


2. HTML meta refresh and redirect page

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.


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 is used to indicate the start time of refresh or redirect and the URL to jump.

The code is as follows: Copy code

<Meta http-equiv = "refresh" content = "3; url = http://www.111cn.net">


3. js page jump

Js redirection mainly uses location objects.

The code is as follows: Copy code

<Script type = 'text/javascript '>
// Jump now
Window. location. href = 'http: // www.111cn.net ';
// Time-limited jump
SetTimeout (function (){
// Jump 3 seconds later
Window. location. href = 'http: // www.111cn.net ';
},3000 );
</Script>

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.