What are the methods to realize automatic jump of php page?

王林
Release: 2023-03-01 14:02:02
Original
4485 people have browsed it

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;
?>
Copy after login

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>
Copy after login

3. Use javascript script to implement

The specific code is as follows:

<?php
$url=index.php;
echo "<!--<SCRIPT LANGUAGE="javascript">";
echo "location.href=&#39;$url&#39;";
echo "</SCRIPT>-->";
?>
Copy after login
<?
//PHP自带函数
Header("Location: http://www.php.com ");
?>
<?
//利用meta
echo "<meta http-equiv=&#39;refresh&#39; content=&#39;0; url=http://www.php.com&#39;>";
?>
Copy after login
<?
//利用Javascript语言
echo "<script language=&#39;javascript&#39;>";
echo "     location=&#39;http://www.php.com&#39; ; ";
echo "</script>";
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template