导航首页 » 技术教程 » PHP mb_convert_encoding文字编码的转换函数介绍
PHP mb_convert_encoding文字编码的转换函数介绍 131 2023-12-09   

文字编码的转换mb_convert_encoding()
mb_convert_encoding( $str, $encoding1,$encoding2 )

$str,要转换编码的字符串
$encoding1,目标编码,如utf-8,gbk,大小写均可
$encoding2,原编码,如utf-8,gbk,大小写均可

实例1

<?php
$str='绿夏网:http://www.gimoo.net';
echo mb_convert_encoding($str, "UTF-8"); //编码转换为utf-8
?>


<?php
$str='绿夏网:http://www.gimoo.net';
echo mb_convert_encoding($str, "UTF-8", "GBK"); //已知原编码为GBK,转换为utf-8
?>


<?php
$str='绿夏网:http://www.gimoo.net';
echo mb_convert_encoding($str, "UTF-8", "auto"); //未知原编码,通过auto自动检测后,转换编码为utf-8
?>

PHP下编码转换函数mb_convert_encoding与iconv的使用说明

!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103