Home >Backend Development >PHP Tutorial >解析php获取字符串的编码格式的方法(函数)_PHP
如果不清楚字符串的编码格式的话,就可以将这段字符这样检查:
$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2312′,"GBK",'BIG5′));
echo $encode;
这样就能知道它是什么编码的了。后续操作还可以为其转码:
if ($encode == “UTF-8″){
$string = iconv("UTF-8″,"GBK",$string);
}