Sinsing and you to interpret the PHP page jump several implementation ways

Source: Internet
Author: User

Because the use of the page jump is very frequent, so here are a few ways, in fact, I think I did not sum up, after all, the function so much, want to think up or is particularly troublesome, so, think of where to remember where to put, waiting for later to tidy up the summary.

The first way is to use the header () function, which is a very simple way to jump page in PHP, its implementation mechanism is to the Htttp protocol header header output to the browser, so in the use of this function and using the Setcookie function, there can be no output, Otherwise it cannot be executed, and its function prototype is as follows:

void header (String string [, bool replace [, int http_response_code]])
For example, the following code will automatically jump to the homepage of Baidu, the code is as follows:

<?phpheader ("location:http://www.baidu.com");
For the above statement, a little bit of the HTTP protocol understand it.

The second way is by using JavaScript, we can output a piece of JavaScript script to the client to execute, for example, we write PHP code as follows, then it will automatically jump to the homepage of Baidu, the code is as follows:

<?php$url = "http://www.baidu.com"; echo "<script> window.location.href= ' $url ' </script>";
This, a little bit of JavaScript can understand, not introduced.

Other ways for a moment did not think, to the almighty reader,, if you have other ideas, please leave a message reply, thank you.

Sinsing and you to interpret the PHP page jump several implementation ways

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.