set_time_limit (0 ); ob_end_clean (); header ("Content-Type: application/force-download" ); header ("Content-type:text/csv;charset=utf-8" ); header ("Content-Disposition: filename=filename" .date ( "Ymd").".csv" ); ob_end_flush (); echo "Title 1, Title 2, Title 3\r" ; echo "Data 1, Data 2, Data 3\r" ;