php 在客户端生成txt文件并且下载

在访问php时生成txt文件

  $filename = 'file.text'; //也可以是其他后缀格式的
    $ua = $_SERVER["HTTP_USER_AGENT"];  
        foreach ($fedexinfo as $key => $value) {
            echo $key.","".$value.""
";
        }
    header("Content-Type: application/octet-stream");  
    header('Content-Disposition: attachment; filename="' .  $filename . '"'); 

 来源:http://jordan-micle.iteye.com/blog/875794

原文地址:https://www.cnblogs.com/share123/p/3653346.html