Home>Article>Backend Development> What should I do if php exports mysql to excel with garbled characters?
The solution for php to export mysql to excel with garbled characters: first set the time zone and header information; then clear the buffer through "ob_end_clean();"; then set the table information; finally query the content and export the database data.
Recommended: "PHP Video Tutorial"
PHP query database export excel and solve the garbled problem, Native code does not require plug-ins
I recently wrote an information system and needed to export the contents of the database to excel
I will post my code below, no phpexcel plug-in is required
System requirements: php5.6
This line of code was not added at the beginning, resulting in garbled output. Just clear the buffer before each data generation,
ob_end_clean();//清除缓冲区,避免乱码
The above is the detailed content of What should I do if php exports mysql to excel with garbled characters?. For more information, please follow other related articles on the PHP Chinese website!