PHP判断变量内容是什么编码(gbk?utf-8) mb_detect_encoding 2020-08-14 16:13:48 浏览数 (1) 代码语言:javascript复制function convToUtf8($str) { if( mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK")!="UTF-8" ) {//判断是否不是UTF-8编码,如果不是UTF-8编码,则转换为UTF-8编码 return iconv("gbk","utf-8",$str); } else { return $str; } } php detect encoding 0 人点赞 上一篇:分享雷军22年前编写的代码