php自動識別編碼,若里面有中文的話,將其轉換為UTF-8就最好了,因為中文在Gbk編輯情況情況下,有可能會亂碼,這個和客戶端和服務端編碼都有關系,為了避免亂碼,我們可以使用下面的函數將其自動轉換為UTF8國際標準編碼:
01 | <?php |
02 | function characet($data){ |
03 | if( !empty($data) ){ |
04 | $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ; |
05 | if( $fileType != 'UTF-8'){ |
06 | $data = mb_convert_encoding($data ,'utf-8' , $fileType); |
07 | } |
08 | } |
09 | return $data; |
10 | } |
11 | ?> |
新聞熱點
疑難解答
圖片精選