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

php汉字编码转换的方法

2024/12/31 1:02:32发布20次查看
php汉字编码转换的方法:1、使用“string iconv()”方法进行转换;2、通过“mb_convert_encoding”方法进行转换;3、使用“mb_detect_encoding”方法进行转换。
推荐:《php视频教程》
一、iconvstring iconv ( string $in_charset , string $out_charset , string $str )
第一个参数:内容原的编码
第二个参数:目标编码
第三个参数:要转的字符串
$filename='我爱你中国';$filename = iconv('gbk','utf-8',$filename);
解析:把$filename从gbk转换为utf8
二、mb_convert_encodingstring 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汉字编码转换的方法的详细内容。
该用户其它信息

VIP推荐

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