php自動識別編碼,若裏面有中文的話,將其轉換爲UTF-8就最好了,因爲中文在Gbk編輯情況情況下,有可能會亂碼,這個和客戶端和服務端編碼都有關係,爲了避免亂碼,我們可以使用下面的函數將其自動轉換爲UTF8國際標準編碼:
<?php function characet($data){ if( !empty($data) ){ $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ; if( $fileType != 'UTF-8'){ $data = mb_convert_encoding($data ,'utf-8' , $fileType); } } return $data; } ?>轉自:http://www.codefans.net/articles/1272.shtml