PHP用MBString库的函数$e=mb_detect_encoding($text, array('UTF-8', 'GBK'));switch($e){case 'UTF-8' : //如果是utf8编码break;case ‘GBK’: //如果是gbk编码break}