您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

PHP输出CSV文件出现乱码问题_PHP教程

2024/4/20 20:17:28发布6次查看
问题:php输入用户列表为csv文件,用excel打开显示为乱码,用记事本或ue打开正常.查看文件编码显示为utf-8
解决:
function down_file($filepath,$filename)
{
if(!file_exists($filepath))
{ www.2cto.com
echo backup error ,download file no exist;
exit();
}
ob_end_clean();
header('content-type: application/download');
header(content-type: text/csv);
header('content-disposition: attachment;filename='.$filename.'');
header(content-encoding: binary);
  header(content-length:.filesize($filepath));
header(pragma: no-cache);
header(expires: 0);
readfile($filepath);
$e=ob_get_contents();
ob_end_clean();
}
$fname='usersdata.csv';
$handle=fopen($fname,'wb');
$strusersdata =iconv('utf-8','gb2312',$strusersdata);//转换编码
if(fwrite($handle,$strusersdata)==false){}
fclose($handle);
down_file($fname,'555.csv');
http://www.bkjia.com/phpjc/477958.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/477958.htmltecharticle问题:php输入用户列表为csv文件,用excel打开显示为乱码,用记事本或ue打开正常.查看文件编码显示为utf-8 解决: function down_file($filepath,$filename...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录