您的位置 首页 技术

php怎么把字符编码转utf8

php把字符编码转utf8的方法: function strToUtf8($str){ $encode = mb_detect_encoding($str, array(&quot…

php把字符编码转utf8的方法:

function strToUtf8($str){    $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'));    if($encode == 'UTF-8'){        return $str;    }else{        return mb_convert_encoding($str, 'UTF-8', $encode);    }}

//mb_convert_encoding('要转编码的字符串','目标编码','原编码')//mb_detect_encoding('字符串'):mb_convert_encoding($str,'utf-8',mb_detect_encoding($str))

推荐教程: 《php教程》

以上就是php怎么把字符编码转utf8的详细内容,更多请关注24课堂在线网其它相关文章!

本文来自网络,不代表24小时课堂在线立场,转载请注明出处:https://www.24ketang.cn/72903.html

为您推荐

返回顶部