php重定向的几种方法

Posted on Posted in php
Tips: 本文创建于2013年11月17日,已超过 2 年,内容或图片可能已经失效!

php重定向的几种方法,来自PHP重定向的具体实现方式

<?php
$url = "www.baidu.com";
if (!emptyempty($url))
{
Header("HTTP/1.1 303 See Other"); //这条语句可以不写
Header("Location: $url"); //Location后面有空格
}
?>

方法二、用META的REFRESH标记

<?php
if (!emptyempty($url))
{
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=$url\">";
}
?>

方法三、用脚本实现

<?
if (isset($url))
{
echo "<SCRIPT LANGUAGE="JavaScript">";
echo "location.href='$url'";
echo "</SCRIPT>";
}
?>
//或者
<?php echo "<script>window.location =\"$url\";</script>";?>
» 转载请注明来源:若我若鱼 » php重定向的几种方法

One thought on “php重定向的几种方法

  1. Firefox 34.0 Firefox 34.0 Windows 8.1 x64 Edition Windows 8.1 x64 Edition
    Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0

    Do you have a spam issue on this blog; I also am a blogger,
    and I was curious about your situation; we have created some nice practices and we are looking to swap methods with others, why not shoot me an email if interested.

Leave a Reply

Your email address will not be published. Required fields are marked *

five × three =