代码:

 
  
  1. header("Content-Type: text/html; charset=utf8"); 
  2. mysql_query("set names utf8"); 

其中的“set names utf8”,至少在我今天所测的时候是不可以写成其它的格式。以下格式,我测试的时候对linux环境下的数据正确读取无效果。

 
  
  1. mysql_query("set names as utf8");//error 
  2. mysql_query("set name utf-8");//error 

前提文件的编码也得统一成utf8.