$str = iconv('UTF-8','GBK',$columNames.$str); //$str为被输出的内容
$filename = date('Ymd').'.txt'; //$filename为点击下载时看到的文件名
header("Content-type:text/txt"); //定义输出的文件格式:txt,csv
header("Content-Disposition:attachment;filename=".$filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0'); header('Pragma:public');
echo $str;