这是一个程序,从当前页面转到你想去的页面
<?php
if($url){
header("location:$url");
}
echo"<html><head>\n";
echo"<title>php</title></head>";
echo"<b>redirect to?</b><br>\n";
echo"<form action=$php_self>\n";
echo"<input type=text size=40 name=url value=http://>
<input type=submit name=submit value=submit><br>";
echo"</p></form>\n";
echo"<html>";
?>
这下你应该会了吧

解决方案 »

  1.   

    easy,还需要解释吗?不过要注意的是header()函数只能在未发出header时使用。
      

  2.   

    不用PHP也可以的
    if($url)
    echo"<meta http-equiv='refresh' content='0,url=".$url."'>";
      

  3.   

    不是的,HEADER函数可以在发出HEADER后使用,只不过要设置缓冲,跟ASP的原理差不多,在ASP中可以用response.buffer = true 然后,使用response.redirect *** response.flush 这样 PHP中也可以,就是,就是,怎么在PHP中实现我给忘了~:)论坛里有这类的帖子~
      

  4.   

    <? 
    ob_start(); //打开缓冲区 
    ?>
    asdf
    <?
    header("location: /index.htm"); //把浏览器重定向到index.php 
    ob_end_flush();//输出全部内容到浏览器 
    ?>我找到了,这样就可以了~
      

  5.   

    还有一种方法就是用PHP写<?echo "<script>location = ''</script>"?>
    这种方法实际上是利用了javascript的location属性,这种方法有一个缺点,也算不上是缺点吧,是特点,就是后退的时候不好用,看情况而定~,如果你不希望用户看到前一个页面就可以这么做~,不过,后退两次也可以看到,你可以在location前加一个alert(),就看不到了~