// 检测字符的编码格式
$encode = mb_detect_encoding($string, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
echo $encode; // 转换编码格式
if ($encode == 'UTF-8'){
$string = iconv('UTF-8','GBK',$string);
}
// 检测字符的编码格式
$encode = mb_detect_encoding($string, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
echo $encode; // 转换编码格式
if ($encode == 'UTF-8'){
$string = iconv('UTF-8','GBK',$string);
}