PHP在unicode時出現亂碼

Published on 01/03,2007

自己最近在試PHP的時候,發現當include一個unicode的檔案進來,會出現下列錯誤:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\www\v3\ortho\classes\GlobalSettings.php:1) in E:\www\v3\ortho\classes\GlobalSettings.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at E:\www\v3\ortho\classes\GlobalSettings.php:1) in E:\www\v3\ortho\classes\GlobalSettings.php on line 3

環境:Appserv on Windows 2000

我試著用記事本把被include的那個檔案另存成UTF-8,還是出現一樣的問題
找了一下資料,似乎是一個叫做BOM(Byte Order Mark)的問題
網路上發現有一些文章可以參考:

-談談Unicode編碼,簡要解釋UCS、UTF、BMP、BOM等名詞
-Unicode、BOM
-用 unicode (UTF-8) 編輯的中文網頁卻出現亂碼

解決方法:
我發現一個免費又不錯用的unicode editor叫做「EmEditor」,它可以在存成UTF-8格式時,不把BOM加上去,這樣程式執行起來就正常了 :)


寫個回應吧

發表回應

回應 PHP在unicode時出現亂碼