header("location:转向的文件");
exit();

解决方案 »

  1.   

    产生如下错误:
    Warning: Cannot modify header information - headers already sent by (output started at c:\apache group\apache\htdocs\etao\includes\header.php:2) in c:\apache group\apache\htdocs\etao\lcupd.php on line 306
    不能实现.我的意思如下,请问如何实现:
    if(true){
        redirect to true.php
    }
    else{
        redirect to false.php
    }
      

  2.   

    header之前不能像浏览器方面输出任何东西。否则无法转向。可一些程序控制转向,但在转向之前不能输出任何东西。
      

  3.   

    if (true) {
        header("location:1.php");
    } else {
        header("location:2.php");
    }注意之间不要有输出。
      

  4.   

    header的使用是前面不能有任何HTML的输出(有echo语句之类的也不行),因此你可以改一下写法,如<?
    if(true)
    {
    echo "<meta http-equiv='refresh' content='0;URL=文件地址'>";
    }else{
    echo "<meta http-equiv='refresh' content='0;URL=文件地址'>";
    }
    ?>也可以这样
    <?
    if(true)
    {
    ?>
    <script language="javascript">
    self.location="转向文件";
    </script>
    <?
    }else{
    ?>
    <script language="javascript">
    self.location="转向文件";
    </script>
    <?
    }
    ?>
      

  5.   

    用javascript;
    <?php
    .
    .
    if(true){
        echo "<script language=javascript>window.location = 'true.php';</script>";
    }
    else{
        echo "<script language=javascript>window.location = 'false.php';</script>";
    }
    .
    .
    ?>
      

  6.   

    直接用php就行了,语句写得紧凑些
      

  7.   

    关于PHP重定向 方法一:header("Location: index.php"); 
    方法二:echo "<script>window.location =\"$PHP_SELF\";</script>"; 
    方法三:echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php\">"; 
    <FORM ACTION="<? echo "$PHP_SELF"; ?>" METHOD="POST">