Home >Backend Development >PHP Problem >What are the methods to realize automatic jump of php page?
There are usually three methods to realize automatic jump of PHP pages:
1. Use Header function
2. Use HTML inherent tags
3. Output javascript and use Js code to achieve the purpose of automatic jump of php page
Let’s take a look at the specific implementation method:
1. Use header function
The function of the HEADER function in PHP is to issue control instructions specified by the HTTP protocol to the browser, which should have been controlled by the WEB server, such as declaring the type of return information ("Context-type: xxxx/xxxx"), page attributes ("No cache", "Expire"), etc.
The method of using HTTP header information to automatically jump to another page in PHP is as follows:
<?php $url = index.php Header("HTTP/1.1 303 See Other"); Header("Location: $url"); exit; ?>
2. Use HTML tags (REFRESH attribute in META)
Use HTML tags, that is, use REFRESH tags of META. The specific code is as follows:
<?php $url = index.php;?> <HTML> <HEAD> <META HTTP-EQUIV="REFRESH" CONTENT="10; URL=<? echo $url;?>> </HEAD> <BODY> </BODY> </HTML>
3. Use javascript script to implement
The specific code is as follows:
<?php $url=index.php; echo "<!--<SCRIPT LANGUAGE="javascript">"; echo "location.href='$url'"; echo "</SCRIPT>-->"; ?>
<? //PHP自带函数 Header("Location: http://www.php.com "); ?> <? //利用meta echo "<meta http-equiv='refresh' content='0; url=http://www.php.com'>"; ?>
<? //利用Javascript语言 echo "<script language='javascript'>"; echo " location='http://www.php.com' ; "; echo "</script>"; ?>
If you want to know more about php, please visit php Chinese website.
The above is the detailed content of What are the methods to realize automatic jump of php page?. For more information, please follow other related articles on the PHP Chinese website!