Redirect to another page in PHP

Source: Internet
Author: User
Tags exit header html tags
How does a page redirect from one page to another in PHP? Here are a list of three options for your reference.

First, with HTTP header information


That is, using the header function of PHP. The function of the header function in PHP is to issue to the browser the control instructions that should have been passed through the Web server, such as declaring the type of return information ("Context-type:xxx/xxx"), the properties of the page ("No cache", " Expire ") and so on.
The way to redirect to another page with HTTP header information is as follows:
?
if (Isset ($url))
{
Header ("http/1.1 303 and Other"); [Thank you, Mr. Li]
Header ("Location: $url");
Exit
}
?>
Notice that "localtion:" There is a space behind it.

Second, with HTML tags


With HTML tags, you use the Meta refresh tag, for example:
? if (!isset ($url)) exit;? >
<HTML>
<HEAD>
<meta http-equiv= "REFRESH" content= "5; url=<? echo $url;? >>
</HEAD>
<BODY>
</BODY>
</HTML>


Three, with the feet to achieve


Examples are as follows:
?
$url = "http://www.phpuser.com";
echo "<!--<script language=" JavaScript ">";
echo "location.href= ' $url '";
echo "</SCRIPT>-->";
?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.