Home  >  Article  >  Backend Development  >  Three ways to learn PHP redirection_PHP Tutorial

Three ways to learn PHP redirection_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 14:52:12733browse

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:

$url = http://www.bkjia.com;
if (isset($url))
{
Header("Location: $url");
}
?>


                                                                                            have a space after there is a space after it. Sometimes it’s okay to leave it out, but for the sake of accuracy it’s better to add it.

2. Mark with HTML

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

$url = http://www.bkjia.com;
if (!isset($url))
{
exit('There is no address to jump to');
}
?>








Note: content="5; url='http://www.bkjia.com' " indicates the jump address and execution after 5 seconds.

3. Use script to implement

$url=http://www.bkjia.com;
echo "";
?>


The best way to use headers is to make the page jump faster. It is not easy for users to visually detect the jump of the entire page, but only a partial change!

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