Home > Backend Development > PHP Tutorial > Summary of common page jump methods in PHP_PHP tutorial

Summary of common page jump methods in PHP_PHP tutorial

WBOY
Release: 2016-07-13 09:57:08
Original
657 people have browsed it

A summary of common page jump methods in PHP

Sometimes users will jump to pages when writing PHP. Here we have collected several good jump methods that can be used.

Using 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 to redirect to another page using HTTP header information is as follows:

The code is as follows:


if (isset($url))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $url");
exit; //
}
?>

Marked with HTML

Use HTML tag, that is, use REFRESH tag of META, for example:

The code is as follows:






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

Use html features

The code is as follows:


echo "< meta http-equiv=\"Refresh\" content=\"number of seconds; url=jumped file or address\" > ";

Where: XX is the number of seconds, 0 means jump immediately. refresh means refresh. Url is the page to jump to.

Use script to implement

The code is as follows:


echo '<script>url="submit.php";window.location.href=url;</script>';

Another implementation using script

Use script to implement, the difference is the use of the open statement. And you can limit the original window to the parent window, child window or new window.

The code is as follows:


<script>url="submit.php";window.open('url,'','_self');</script>

Change '_self' to limit the jump to the original window, parent window, child window or new window. The seventh method: use PHP's own function to send header information

The code is as follows:


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/984502.htmlTechArticleA summary of common page jump methods in php. Sometimes user pages will jump when writing php. Here are a few collected A good jump method can be used. Implemented using HTTP header information, that is, using...
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template