这段代码导出sql数据到csv文件,数据是出来了,显示在网页上,不保存成csv文件,请教一下什么原因? if (isset($_POST['export'])) { $sql = 'SELECT col1, col2, col3 FROM `sheet1`'; $result = $conn->query($sql); if ($result === FALSE) { echo "Error fetching data: " . $conn->error . ""; } elseif ($result->num_rows > 0) { // create a file pointer connected to the output stream $output = fopen('php://output', 'w'); // output the column headings fputcsv($output, ['col1', 'col2', 'col3']); // loop over the rows, outputting them while ($row = $result->fetch_assoc()) fputcsv($output, $row); // Output CSV-specific headers header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=data.csv'); fclose($output); exit; } else { echo "0 results"; } $conn->close(); }