最新消息:本站所有跳转向bbs.ykit.cn的附件将全面停止,附件已转移到https://www.qingsj.com

php转换字符编码为utf-8

PHP 有客 274浏览
//php转换字符编码为utf-8
function strToUtf8( $str ) {
	$encode = mb_detect_encoding( $str, array( "ASCII", 'UTF-8', "GB2312", "GBK", 'BIG5' ) );
	if ( $encode == 'UTF-8' ) {
		return $str;
	} else {
		return mb_convert_encoding( $str, 'UTF-8', $encode );
	}
}

转载请注明:有客帮 » php转换字符编码为utf-8