2009年3月17日

MySQL和php採用UTF8的詳細方法

1. PHP 程式檔本身的編碼格式是 utf8
2. MySQL 資料表的欄位的校對屬性設為 utf8_unicode_ci,就是欄位加上 collate utf8_unicode_ci
3. PHP 在與 MySQL 溝通時,要先送出 SET NAMES utf8
4. PHP 在輸出畫面前,要先送出 header('Content-type: text/html; charset=utf-8');

可參考網頁:
http://www.vixual.net/blog/archives/315
http://www.vixual.net/blog/archives/310

沒有留言: