Summary of common page jump methods in PHP

Source: Internet
Author: User

PHP in the writing will sometimes user page jump, here collected a few good jump methods, you can use.

Using HTTP header information to implement

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:

The

code is as follows:


;?


if (isset ($url))


{


Header ("http/1.1 303");


Header ("Location: $url");


exit; //


}


?>

Using HTML tags

With HTML tags, you use the Meta refresh tag, for example:

The

code is as follows:


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


<HTML>


<HEAD>


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


</HEAD>


<BODY>


</BODY>


</HTML>

With the script to achieve

The

code is as follows:


;?


$url = "Http://www.3LIAN.net";


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


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


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


?>

Leveraging HTML Features

The

code is as follows:


echo "< meta http-equiv=" Refresh "content=" number of seconds; Url= jump to the 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 which you want to jump.

Using script to implement

The

code is as follows:


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

Another way to use script implementation

Using the script implementation, the difference is to use the Open statement. And you can restrict whether the original window is a parent window, a child window, or a new window.

The

code is as follows:


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

Where change ' _self ' can be implemented to restrict the original window or the parent window, the child window, or the new window. Seventh: Use PHP to send the head information with a function

The

code is as follows:


header ("Location:url");

Fast, powerful ... But there is one problem that must be noted: If you have HTML output before using this function, even a space. The error message appears at the top of the page ...

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.