Home  >  Article  >  Backend Development  >  Sharing three methods of php redirection_PHP tutorial

Sharing three methods of php redirection_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:20:15703browse

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. For example: declare 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:

< ;?php
$url = "http://www.jb51.net";
if (isset($url))
{
Header("Location: $url");
}
?>

Note: There is a space after "Localtion:". Sometimes it is okay not to add it, but for the sake of accuracy it is better to add it.

2. Use HTML tags

Use HTML tags, that is, use META’s REFRESH tag, for example:
Copy code The code is as follows:

$url = "http://www.jb51.net";
if (!isset($url))
{
exit('No address to jump');
}
?>








Note: content="5; url='http://www.jb51.net' ", indicating the jump address and 5 seconds later implement.

3. Use script to implement
Copy the code The code is as follows:

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


However, I personally prefer the header method, so that the page jumps faster, and the user cannot visually detect the full page jump, but only a partial jump. changes!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325142.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