[php]生成下载CSV文件

php生成csv文件非常简单,只要告诉浏览器header类型就可以了

header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=文件名.csv ");
//然后echo一个逗号分隔的多行字符串就可以了

/*1,2,3

4,5,6

*/

echo $file;