新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

php把字符串转为utf-8的方法-创新互联

小编给大家分享一下php把字符串转为utf-8的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

创新互联主营乐清网站建设的网络公司,主营网站建设方案,app软件开发,乐清h5微信小程序开发搭建,乐清网站营销推广欢迎乐清等地区企业咨询

php把字符串转为utf-8的方法:首先找出字符串本身的编码;然后通过“mb_convert_encoding($str, 'UTF-8', $current_encode);”方法把字符串转为utf-8即可。

php把字符串转为utf-8的方法

php将任意编码的内容转换成utf-8

先找出字符串本身的编码,再转换为utf-8编码。

方法

function str_to_utf8 ($str = '') {
    $current_encode = mb_detect_encoding($str, array("ASCII","GB2312","GBK",'BIG5','UTF-8')); 
    $encoded_str = mb_convert_encoding($str, 'UTF-8', $current_encode);
    return $encoded_str;
}

看完了这篇文章,相信你对php把字符串转为utf-8的方法有了一定的了解,想了解更多相关知识,欢迎关注创新互联-成都网站建设公司行业资讯频道,感谢各位的阅读!


分享标题:php把字符串转为utf-8的方法-创新互联
文章来源:http://www.wjwzjz.com/article/cdodjs.html
在线咨询
服务热线
服务热线:028-86922220
TOP