The results are in! See what nearly 90, developers picked as their most loved, dreaded, and desired coding languages and more in the Developer Survey. PHP Solution. Now all that's left to do is for that PHP file to read the contents of the CSV file and print them - the filename=xbook.info in the header only suggests to the client browser what name to use for the file, it does not actually fetch the data from the file on the server. May 01, · Proper PHP Headers for CSV Documents (All Browsers) The following CSV document header code example has been tested and works in all major browsers. When run, it will generate a CSV file using PHP, store it in a variable called CSV, then echo the contents of the CSV to the browser. (Note: For this to work properly this needs to be. If you would like to force a file download prompt to the user, instead of just outputting the text to the browser, use the following headers. php. How to use PHP to create downloadable CSV files for exporting data. so that the file is downloaded rather than displayed header('Content-Type: text/csv;. The following CSV document header code example has been tested and works in all major browsers. When run, it will generate a CSV file.