Home > Article > Backend Development > How to implement timed jump in PHP page, PHP page jump_PHP tutorial
The example in this article describes how to implement scheduled jumps on PHP pages, and is shared with everyone for your reference. The specific implementation method is as follows:
PHP scheduled jump We need to use the header function to enter html or js code to achieve scheduled jump. Let me introduce a simple example below
The php code is as follows:
What needs to be noted here is: if your file is uft-8 encoded, we must be careful not to have output or BOM characters before the header, which may cause the jump to fail.
I hope this article will be helpful to everyone’s PHP programming design.
Php itself does not have a complete page jump function. Maybe the Header function is one, but it can only be used for the first line of the page. If placed at the end of the Php page, unless the previous Php does not output any characters, an error will be reported. The following are three methods for automatic page jump in Php:
1: Use the Header function.
Two: Use HTML inherent tags. (Not only applicable to Php, but also applicable to ASP, .Net, and Jsp).
Three: Output javascript and use Js code to achieve the purpose of automatic jump to the Php page. (It also applies to languages other than Php, but the corresponding language codes are different). 1. Use HTTP header information (Header function)
that is, use PHP’s HEADER function. The function of the HEADER function in PHP is to issue control instructions to the browser that should be passed through the WEB server specified by the HTTP protocol, such as declaring the type of return information ("Context-type: xxxx/xxxx"), the attributes of the page ("No cache", "Expire"), etc.
The method to use HTTP header information to make Php automatically jump to another page is as follows:
$url = index.php
Header("HTTP/1.1 303 See Other") ;
Header("Location: $url");
exit;
?>
Note that there is a space after "Localtion:". 2. Use HTML tags (REFRESH attribute in META)
Use HTML tags, that is, use META’s REFRESH tag. For example:
< ;HTML>