1. Use PHP’s header function
That is, use PHP’s header function. The function of the header function in PHP is to issue control instructions to the browser that should be passed through the WEB server specified by the HTTP protocol, such as declaring the type of return information ("Context-type: xxx/xxx"), the attributes of the page ("No cache", "Expire"), etc.
The method of using HTTP header information to redirect PHP to another page is as follows:
<?php $url = "www.yaojinbu.com"; if (!empty($url)) { header("HTTP/1.1 303 See Other"); //这条语句可以不写 header("Location: $url"); } ?>
Note: There is a space after "Localtion:".
2. Use HTML meta tag
Use HTML tag, that is, use META REFRESH tag, for example:
<?php if (!empty($url)) { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=$url\">"; } ?>
3. Use JavaScript script function
For example:
<?php if (isset($url)) { echo "<SCRIPT LANGUAGE="JavaScript">"; echo "location.href='$url'"; echo "</SCRIPT>"; } ?>
or
<?php echo "<script>window.location =\"$url\";</script>";?>