版权声明:欢迎任何形式的转载,但请务必注明出处,共创知识服务 https://blog.csdn.net/ASUKA2020/article/details/84495557
<?php
$file = 'Hello,World';
$csv_data = mb_convert_encoding($file, "cp936", "UTF-8");
$file_name = time().'.csv';
header("Content-type:text/csv;");
header("Content-Disposition:attachment;filename=" . $file_name);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
echo $csv_data;
```