温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php导入时如何设置不同的编码

发布时间:2021-05-06 10:47:34 来源:亿速云 阅读:113 作者:小新 栏目:编程语言

这篇文章主要介绍了php导入时如何设置不同的编码,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

php有什么特点

1、执行速度快。2、具有很好的开放性和可扩展性。3、PHP支持多种主流与非主流的数据库。4、面向对象编程:PHP提供了类和对象。5、版本更新速度快。6、具有丰富的功能。7、可伸缩性。8、功能全面,包括图形处理、编码与解码、压缩文件处理、xml解析等。

php导入到excel-支持utf8和gbk两种编码

1、utf-8编码案例

php导入到excel乱码,是因为utf8编码在xp系统不支持所有utf8编码,转码一下就完美解决了。

<?php
header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment;filename=www.niutw.com.xls ');
header('Content-Transfer-Encoding: binary ');
?>
<?
$filename='php导入到excel-utf-8编码';
filename=iconv('utf-8', 'gb2312',filename=iconv(
′
 utf−8
′
 ,
′
 gb2312
′
 ,filename);
echo $filename;
?>

2、gbk编码案例

<?php
header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment;filename=www.iiwnet.com.xls ');
header('Content-Transfer-Encoding: binary ');
?>
<?
$filename='php导入到excel-utf-8编码';
echo $filename;
?>

访问网站的时候就下载到excel里面,要弄单元格区别的话,用table表格做网页的就可以了。

感谢你能够认真阅读完这篇文章,希望小编分享的“php导入时如何设置不同的编码”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI