PHP page jump to another page of the various methods summary

Source: Internet
Author: User

First, with the HTTP header information

That is, with header function. header web ( "Context-type: xxx/xxx") ("No cache",  "Expire") and so on.  

The following methods are used to redirect HTTP header information to another page:

Copy the code code as follows :

<?

if (Isset ($url))

{

Header ("http/1.1 303 See other");

Header ("Location: $url");

Exit From www.w3sky.com

}

?>

Notice that"localtion:" has a space behind it.

Second, with HTML tags

Use HTML markup , which is the REFRESH tag of META , for example:

Copy the code code as follows :

<? if (!isset ($url)) exit;? >

<HTML>

<HEAD>

<meta http-equiv= "REFRESH" content= "5; url=<? echo $url;? >>

</HEAD>

<BODY>

</BODY>

</HTML>

Third, the use of the script to achieve

Examples are as follows:

Copy the code code as follows :

<?

$url = "Http://www.jb51.net";

echo "<!--<scrīpt language=" Javascrīpt ">";

echo "location.href= ' $url '";

echo "</scrīpt>-->";

?>

Here are the supplemental

The fourth type :

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

where : XX is the number of seconds , 0 for immediate jump . Refresh is the meaning of refreshing . The Url is the page to jump to .

The fifth type : using script to implement

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

The sixth type: using script implementation , the difference is to use the open statement . and can restrict the original window or the parent window , child window or new window . 

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

where the change \ ' _self\ ' can implement a jump to restrict the original window or parent window , child window or new window . Seventh Type : Use PHP Send header information with the self-function

Header ("Location:url");

The fastest and most powerful ... But there is one question that must be pointed out : If you have already used this function before HTML Output , even if it's a space . then the error message will be displayed at the top of the page .. 

PHP page jump to another page of the various methods summary

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.