尝试:
header("Content-type: text/csv");header("Content-Disposition: attachment; filename=file.csv");header("Pragma: no-cache");header("Expires: 0");echo "record1,record2,record3n";die;等等
编辑:这是我用来选择性编码CSV字段的代码片段:
function maybeEnpreCSVField($string) { if(strpos($string, ',') !== false || strpos($string, '"') !== false || strpos($string, "n") !== false) { $string = '"' . str_replace('"', '""', $string) . '"'; } return $string;}


