What could be causing the issue of the CSV file being output online instead of prompting for download?

The issue of the CSV file being output online instead of prompting for download is likely due to missing HTTP headers that specify the file as an attachment. To solve this issue, you can add the "Content-Disposition" header with the value "attachment" to force the browser to prompt for download.

<?php
// Set headers to force download
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="filename.csv"');

// Output CSV data
echo "Name, Age, Email\n";
echo "John Doe, 30, john.doe@example.com\n";
echo "Jane Smith, 25, jane.smith@example.com\n";
?>