Home >Backend Development >PHP Tutorial >PHP 导出csv文件乱码解决方案

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:43:231181browse

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

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

加上之后就可以正常了。



Statement:
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
Previous article:php xss过滤Next article:最简单的PHP开发环境搭建