//一般情况下用 iconv,只有当遇到无法确定原编码是何种编码,或者iconv转化后无法正常显示时才用mb_convert_encoding 函数.
<?php $str='编码'; echo mb_convert_encoding($str, "UTF-8", "auto"); //未知原编码,通过auto自动检测后,转换编码为utf-8 ?>
<?php $str='编码'; echo mb_convert_encoding($str, "UTF-8", "GBK"); //已知原编码为GBK,转换为utf-8 ?>
<?php $str='编码'; echo mb_convert_encoding($str, "UTF-8"); //编码转换为utf-8 ?>
iconv('GB2312', 'UTF-8', $str); //将字符串的编码从GB2312转到UTF-8