public function exportCsv($filepath, $data = [], $header = []){ $file = fopen($filepath, 'w'); // 添加 BOM,解除中文乱码 fwrite($file, chr(0xEF).chr(0xBB).chr(0xBF)); // 输入头 if ($header) { fputcsv($file, $header); } // 输入数据 foreach ($data as $item) { fputcsv($file, $data); } fclose($file); return $filepath; }