文字编码的转换mb_convert_encoding()
mb_convert_encoding( $str, $encoding1,$encoding2 )
$str,要转换编码的字符串
$encoding1,目标编码,如utf-8,gbk,大小写均可
$encoding2,原编码,如utf-8,gbk,大小写均可
实例1
复制代码 代码如下:
<?php
$str='脚本之家:http://www.uoften.com';
echo mb_convert_encoding($str, "UTF-8"); //编码转换为utf-8
?>
复制代码 代码如下:
<?php
$str='脚本之家:http://www.uoften.com';
echo mb_convert_encoding($str, "UTF-8", "GBK"); //已知原编码为GBK,转换为utf-8
?>
复制代码 代码如下:
<?php
$str='脚本之家:http://www.uoften.com';
echo mb_convert_encoding($str, "UTF-8", "auto"); //未知原编码,通过auto自动检测后,转换编码为utf-8
?>
PHP下编码转换函数mb_convert_encoding与iconv的使用说明
最后
以上就是现代芝麻最近收集整理的关于PHP mb_convert_encoding文字编码的转换函数介绍的全部内容,更多相关PHP内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复