header执行的时候前面已经有header的信息输出了,这个时候来修改有问题你可以用ob_...来做,或者放在开头

解决方案 »

  1.   

    详细http://www.yourinspirationweb.com/en/php-tips-warning-cannot-modify-header-information-lets-get-things-straight/
      

  2.   

    Warning: Cannot modify header information
      

  3.   

    编写如下自定义函数
    <?php
    $url=127.0.0.1:8888;
    function message($url){
        //echo "<script>window.location.href='$url';</script>";
       
        echo "<script>alert('aa');location.href='$url';</script>";
    }
    message($url);
    ?>
    证明是行不通的。我的写法有错吗?求解window.location.href和location.href调试成功的用法,并且这两个与heards的关系及区别
      

  4.   

    <?php
    $url='http://127.0.0.1:8888';//或者$url = "http://www.baidu.com";
    function message($url){
        echo "<script>alert('aa');location.href='$url';</script>";
    }
    message($url);
    ?>
      

  5.   

    Warning: Cannot modify header information -  (output started at index.php:1) in index.php on line 78
    警告:无法修改标题信息 - (输出开始的index.php:1)在index.php文件上线78
    很明显,你的 index.php 有 bom 头 或者多了一个空行(空格)
    这样 78 行的 setcookie(message, $message); 就会有这个错误