1. First, we will use the usage of header() in php
Here you can refer to the PHP header() function in w3school and p
The header() function is called before any actual output is sent.
The following is an example of using php to output csv.
1. Define the header() header output format
header("Content-type:application/vnd.ms-excel"); //Define the output File type
header(“content-Disposition:filename=downloaded.pdf
”); //Define the output file name, that is, set a download type, and rename the file when downloading
You can open the php file at this time and you will be prompted to download it.
can also be output in the form of a table;
CSV writing operation:
For the usage of fputcsv(), please refer to.