Home  >  Article  >  Backend Development  >  Summary of various methods for jumping from a PHP page to another page

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

高洛峰
高洛峰Original
2017-01-21 13:58:371508browse

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 
} 
?>

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>

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>-->"; 
?>

The following is a supplement
The fourth method:
echo "b037586d08818f2485d1dd203da72e80url="submit.php";window.location.href=url;2cacc6d41bbb37262a98f745aa00fbf0

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.
3f1c4e4b6b16bbbd69b2ee476dc4f83aurl="submit.php";window.open(\'url,\'\',\'_self\');3fa3f474cbb4b6d948eebecb1be5dde4
Change \'_self\' to limit the jump to the original window, parent window, child window or new window. The seventh way: use PHP's own function to send header information
header("Location : Url");

The fastest and most powerful... But there is a problem that must be pointed out: if there is already html output before using this function, even if it is a space, then an error will be displayed at the top of the page Information..

For more PHP pages to jump to another page, various methods and methods to summarize related articles, please pay attention to the PHP Chinese website!

Statement:
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