在有任何输出前先设置头:
header('Content-type: text/html; charset=utf-8');
连接上数据库后设置读取时候的编码:
header('Content-type: text/html; charset=utf-8');
连接上数据库后设置读取时候的编码:
mysql_query("SET NAMES 'UTF8'");
set names 'utf8'相当于
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
原因:http://blog.csdn.net/ZSMJ_2011/article/details/7943734