PHP 导出csv文件乱码解决方案

WBOY
Release: 2016-06-23 13:43:23
Original
1135 people have browsed it

最近在开发一个导出csv文件数据,到含有中文的时候会乱码,现在发现了一个很好的解决方案,就是再fwrite前加入一行代码即可。

$fp = fopen("order.csv", "a");//在写入数据之前先把bom头写到文件里  fwrite($fp,"\xEF\xBB\xBF");  $p=fwrite($fp,$str); // 写入数据fclose($fp);
Copy after login

加上之后就可以正常了。



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template