Cannot modify header information - headers already sent by (output --------------------------------------------------------------------------------
header在之前已经发出,不能改了,你在程序开始加上ob_start(),结尾加上ob_end_flush(),就ok了

解决方案 »

  1.   

    开始加上ob_start(),结尾加上ob_end_flush(),
    加了是可以了,请问这两个函数的作用???
      

  2.   

    b.php<?php
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=".$_GET['name']);
    header("Content-Description: PHP3 Generated Data");
    readfile($_GET['path'].$_GET['name']);
    ?>
      

  3.   

    <?php
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=".$_GET['name']);  
    readfile($_GET['path'].$_GET['name']);
    header("Content-Description: PHP3 Generated Data");
    ?>改成<?php
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=".$_GET['name']);  
    header("Content-Description: PHP3 Generated Data");
    readfile($_GET['path'].$_GET['name']);
    ?>
    应该也可以的。输出内容应该放在所有改变header信息的语句之前
      

  4.   

    开始加上ob_start(),结尾加上ob_end_flush(),
    加了是可以了,请问这两个函数的作用???
    ------------------------------------------------
    因为你readfile函数是读入一个文件并写入到输出缓冲,要是不用ob_end_flush(),缓存输出,然后执行header("Content-Description: PHP3 Generated Data");就要出错。因为执行header("Content-Description: PHP3 Generated Data");之前不能有输出。
    在最开始加上ob_start(),是控制缓存输出开始,结尾加上ob_end_flush(),是控制缓存输出结束,
    在header("Content-Description: PHP3 Generated Data");之后用ob_end_flush(),就是控制缓存输出在header语句之后进行完毕。这样就不会出错了