PHP mb_convert_encoding文字编码的转换函数介绍
PHP mb_convert_encoding文字编码的转换函数介绍
发布时间:2016-12-29 来源:查字典编辑
摘要:文字编码的转换mb_convert_encoding()mb_convert_encoding($str,$encoding1,$encod...

文字编码的转换mb_convert_encoding()

mb_convert_encoding( $str, $encoding1,$encoding2 )

$str,要转换编码的字符串

$encoding1,目标编码,如utf-8,gbk,大小写均可

$encoding2,原编码,如utf-8,gbk,大小写均可

实例1

复制代码 代码如下:

<?php

$str='查字典教程网:http://www.jb51.net';

echo mb_convert_encoding($str, "UTF-8"); //编码转换为utf-8

?>

复制代码 代码如下:

<?php

$str='查字典教程网:http://www.jb51.net';

echo mb_convert_encoding($str, "UTF-8", "GBK"); //已知原编码为GBK,转换为utf-8

?>

复制代码 代码如下:

<?php

$str='查字典教程网:http://www.jb51.net';

echo mb_convert_encoding($str, "UTF-8", "auto"); //未知原编码,通过auto自动检测后,转换编码为utf-8

?>

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类