php中文编码如何转换(php,编程语言)

时间:2024-05-04 14:22:19 作者 : 石家庄SEO 分类 : 编程语言
  • TAG :

php中文编码转换的方法:1、使用iconv函数,代码为【string iconv (string $in_, string $out_, string $str)】;2、使用【mb_convert_encoding】函数。

php中文编码转换的方法:

一、iconv

string iconv ( string $in_charset , string $out_charset , string $str )

第一个参数:内容原的编码

第二个参数:目标编码

第三个参数:要转的字符串

$filename='我爱你中国';$filename = iconv('gbk','utf-8',$filename);

解析:把$filename从gbk转换为utf8

二、mb_convert_encoding

string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding ] )

第一个参数:要处理的字符串

第二个参数:目标编码

第三个参数:内容原编码

$filename='我爱你中国';$filename = mb_convert_encoding($filename,'GBK','UTF-8');

解析:把$filename从utf8转换为gbk

三、mb_detect_encoding查看字符编码

$filename='我爱你中国';$encode = mb_detect_encoding($filename, array("ASCII","UTF-8","GB2312","GBK","BIG5"));echo $encode;die;

在这里插入图片描述

php中文编码如何转换


 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:php中文编码如何转换的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:php下载excel乱码怎么办下一篇:

9 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18