Summary of various methods for jumping from a PHP page to another page

高洛峰
Release: 2023-03-05 08:44:01
Original
1555 people have browsed it

1. Use HTTP header information
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: xxx/xxx"), the attributes of the page ("No cache", "Expire"), etc.
The method of redirecting to another page using HTTP header information is as follows:

<? 
if (isset($url)) 
{ 
Header("HTTP/1.1 303 See Other"); 
Header("Location: $url"); 
exit; //from www.w3sky.com 
} 
?>
Copy after login

Note that there is a space after "Localtion:".
2. Use HTML tags
Use HTML tags, that is, use META’s REFRESH tag. Examples are as follows:

<? if (!isset($url)) exit;?> 
<HTML> 
<HEAD> 
<META HTTP-EQUIV="REFRESH" CONTENT="5; URL=<? echo $url;?>> 
</HEAD> 
<BODY> 
</BODY> 
</HTML>
Copy after login

3. Use scripts to implement
Examples are as follows:

<? 
$url="http://www.php.cn"; 
echo "<!--<scrīpt LANGUAGE="Javascrīpt">"; 
echo "location.href=&#39;$url&#39;"; 
echo "</scrīpt>-->"; 
?>
Copy after login

The following is a supplement
The fourth method:
echo "< meta http-equiv=\\"Refresh\\" content=\\"number of seconds; url=jumped file or address\\" > ; ";
Where: XX is the number of seconds, 0 is an immediate jump. refresh means refresh. Url is the page to jump to.

The fifth way: use script to achieve
<script>url="submit.php";window.location.href=url;</script>

Sixth method: Use script to implement, the difference is to use the open statement. And it can be restricted The original window is still a parent window, a child window or a new window.

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template