1介紹 mb_convert_encoding( $str, $encoding1,$encoding2 ) $str,要轉換編碼的字符串 $encoding1,目標編碼,如utf-8,gbk,大小寫均可 $encoding2,原編碼,如utf-8,gbk,大小寫均可 2實例1 <?php $str='編碼'; echo mb_convert_encoding($str, "UTF-8"); //編碼轉換為utf-8 ?> 3實例2 <?php $str='編碼'; echo mb_convert_encoding($str, "UTF-8", "GBK"); //已知原編碼為GBK,轉換為utf-8 ?> 4實例3 <?php $str='編碼'; echo mb_convert_encoding($str, "UTF-8", "auto"); //未知原編碼,通過auto自動檢測後,轉換編碼為utf-8 ?>
URL:http://www.bianceng.cn/webkf/PHP/201410/45960.htm