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

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

WBOY
WBOYOriginal
2016-07-21 15:45:38660browse

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:

Copy the code The code 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 the REFRESH tag of META, for example:
Copy code The code is as follows:




Copy codeThe code is as follows:

$url="http://www.jb51.net";
echo "";
?>

The following is the supplementary
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: 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.
<script>url="submit.php";window.open('url,'','_self');</script>
Changing '_self' can limit the jump to the original window, the parent window, a child window or a new window. The seventh method: 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 message will be displayed at the top of the page.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320315.htmlTechArticle1. 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, for example...
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