PHP page to achieve regular jump, php page Jump

Source: Internet
Author: User

PHP page to achieve regular jump, php page Jump

This article describes how to implement regular jump on the PHP page and shares it with you for your reference. The specific implementation method is as follows:

For php scheduled jump, we need to use the header function to input html or js Code for scheduled jump. Here is a simple example.

The php code is as follows:

Copy codeThe Code is as follows: header ("refresh: 3; url = http://www.bkjia.com ");
Print ('loading... please wait. <br> the page will automatically jump to the customer's house in three seconds ~~~ ');
The output html code is
Copy codeThe Code is as follows: <meta http-equiv = "refresh" content = "3; url = http://www.bkjia.com"> same effect.
In this way, automatically jump to the http://www.bkjia.com after 3 seconds.

Note that if your file is uft-8 encoded, we should be careful not to have the output or BOM character before the header, which may cause the jump to fail.

I hope this article will help you with PHP programming.


How to automatically jump to a php page 15 seconds later

Php itself does not have a fully functional page Jump function. Maybe the Header function is regarded as one, but it can only be used for the first line of the page. If it is placed at the end of the Php page, an error will be reported unless the preceding Php does not output any characters. The following are three Php automatic page Jump methods:
I. Use the Header function.
Ii. Use inherent HTML tags. (Applicable not only to Php, but also to ASP,. Net, and Jsp ).
3. Output javascript code to automatically redirect Php pages. (It is also applicable to languages other than Php, but the corresponding language code is different ). 1. Use HTTP Header information (Header function)
That is, use the php header function. The HEADER function in PHP is used to send control commands that should have been specified by the HTTP protocol to the browser through the WEB server, such as declaring the type of returned information ("Context-type: xxxx/xxxx "), page attributes (" No cache "," Expire "), and so on.
You can use the HTTP header to automatically redirect Php to another page as follows:
<? Php
$ Url = index. php
Header ("HTTP/1.1 303 See Other ");
Header ("Location: $ url ");
Exit;
?>
Note that "Localtion:" is followed by a space. Ii. Use HTML tags (REFRESH attribute in META)
The HTML Tag is the REFRESH tag of META, for example:
<? Php $ url = index. php;?>
<HTML>
<HEAD>
<META HTTP-EQUIV = "REFRESH" CONTENT = "10; URL = <? Echo $ url;?>
</HEAD>
<BODY>
</BODY>
</HTML>
Note: CONTENT = "10 indicates that the jump will take 10 seconds. Iii. implemented using javascript scripts
Example:
<? Php
$ Url = index. php;
Echo "<! -- <Script language = "javascript"> ";
Echo "location. href = '$ url '";
Echo "</SCRIPT> --> ";
?>
Bytes ---------------------------------------------------------------------------------------------------------------
<?
// PHP built-in functions
Header ("Location: www.php.com ");
?>
<?
// Use meta
Echo "<meta http-equiv = 'refresh' content = '0; ...... the remaining full text>

PHP page Jump implementation methods

Haha? Are you sure you want? Header ('location: index. php'); I often write this to redirect the page to the home page. Isn't index. php a relative path?
In addition, header ('location: test/test113.php '); can also be written.

You may have made a mistake. When the relative path is written in the header, the script is executed. For example
Write in test. php under the include folder
<? Header ('location: index. php');?>
Use test2.php in the another folder to include it.
<? Include '../include/test. php';?>
When accessing test2.php, the index. php under another is displayed.
When accessing test. php, the index. php under include is switched

--------------- Split line ------------------
If you are satisfied, please adopt (⊙ o ⊙). The above is the answer provided by the hardware and software Qian Shi team.
If you have any questions, you can ask me or my team any questions in the future. (* ^__ ^ *) Xi ......

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.