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