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 ="); // time-limited jump
Header ('Location: '); // 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 =">

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: // ';
// Time-limited jump
SetTimeout (function (){
// Jump 3 seconds later
Window. location. href = 'http: // ';
},3000 );

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.