在使用header之前不能有任何输出
如果你以本页之前有输出了,那就不能用这个了,转用javascript吧。

解决方案 »

  1.   

    在使用header之前不能有任何输出
    如果代码仅仅就:
    <?php
    Header("Location: http://www.php.net");
    exit;
    ?>
    的话是可以执行的,
    如果在header页有输出连着他的话就不可能执行,改成:
    <Script language=javascript>window.location.href='yoururl'</script>
      

  2.   

    可我删除了上面一段
    <?php
    $count++;
    setcookie("count",$count);
    ?>
    welcome! You bee
    <?php
     echo($count.($count==1?"time!":"times!"));?>
    还是报同样的问题
    Warning: Cannot modify header information - headers already sent by (output started at D:\web\counte.php:2) in D:\web\counte.php on line 4
    welcome! You bee 1time!
      

  3.   

    在<?php 与?>前后都不要用空行,空格也不要用,不然就会出那样的错误的
      

  4.   

    调试通过!
    <?
    $count++;
    setcookie("count",$count);
    ?>
    welcome! You bee 
    <?
     echo($count."&nbsp".($count==1?"time!":"times!"));
    ?>
      

  5.   

    检查你的<??>标签前面是否有空格、空行
      

  6.   

    修改php.inisession.auto_start = 1
      

  7.   

    开始
    <?php
    Header("Location: http://www.php.net");
    exit;
    ?>
    报错
    at D:\web\counte.php:2) in D:\web\counte.php on line 3
    注意:2 和 3
    后来
    <?php
    $count++;
    setcookie("count",$count);
    ?>
    报错
    at D:\web\counte.php:2) in D:\web\counte.php on line 4
    注意:2 和 4可见你的第一行是空行,删掉就可以了
      

  8.   

    还是不行啊!!
    ##########
    <?php
    Header("Location: http://www.php.net");
    exit;
    ?>
    #########
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.
    --------------------------------------------------------------------------------Apache/2.0.43 Server at localhost Port 80
    #########
    谁知道为什么啊!!我快疯了!!
      

  9.   

    我用下程序同样的错,是不是 php.ini 那要修改啊!!
    <?php
      if (!isset($_SERVER['PHP_AUTH_USER'])) {
        header('WWW-Authenticate: Basic realm="My Realm"');
        header('HTTP/1.0 401 Unauthorized');
        echo 'Text to send if user hits Cancel button';
        exit;
      } else {
        echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
        echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
      }
    ?>
      

  10.   

    重起一下apache接着网页里面什么也不要有,只在网页开始的时候加上
    <?php
    Header("Location: http://www.php.net");
    ?>如果你只是想跳转,也不妨试试,echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=main.php'>";
    如果这都不成,那就看看你的配置问题,恐怕php配置都有问题!
      

  11.   

    你那方法可以,可我的所有的跳转都是用header写的.我很想知道我的php.ini 是那错了???
      

  12.   

    Location改为本地IP试一下!如果不行,就是PHP。INI的问题
      

  13.   

    我在用header ,进行身份验证的时候也是老是出问题,
    真是气人,
    它说   什么已经  sent 
    不知道是怎么回事???