PHP export CSV when data having UTF8 charcters

后端 未结 4 1466
花落未央
花落未央 2021-02-14 03:49

In MySQL I have set my data field type to utf8_bin and i am storing data in Unicode. Texts are being properly displayed in web pages.

I want to generate ex

4条回答
  •  旧巷少年郎
    2021-02-14 04:45

    Try following code;

    ob_end_clean();
    $_filename = date('Y_m_d_H_i').".csv";
    
    header("Cache-Control: public"); 
    header("Content-Type: application/octet-stream");
    header("Content-Type: text/csv; charset=utf-8");
    header("Content-Disposition: attachment; filename=$_filename");
    // Read the file from disk
    readfile($filename);
    exit();
    

提交回复
热议问题