php Thinkphp 字符转utf8

/**
 * # +========================================================================
 * # | - @name        转码utf8
 * # | - @author     cq <[email protected]> 
 * # | - @copyright zmtek 2018-11-07
 * # +------------------------------------------------------------------------
 * # | - 1首页
 * # +========================================================================
 */
function characet($data){
    
    if( !empty($data) ){
        $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
        
        if( $fileType != 'UTF-8'){
            
            $data = mb_convert_encoding($data ,'utf-8' , $fileType);
        }
    }
  return $data;
}

猜你喜欢

转载自www.cnblogs.com/leaf-cq/p/11715545.html