如何转换

php 字符串如何转utf8

编程开发 2020-10-10 02:16:28 27

导读

PHP转换字符编码为utf-8function strToUtf8($str){ $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); if($encod……

PHP转换字符编码为utf-8

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);
    }
}


1253067 TFnetwork_cn