确保与数据库的连接也使用此字符集:
$conn = mysql_connect($server, $username, $password);mysql_set_charset("UTF8", $conn);根据
mysql_set_charsetphp.net 的文档:
Note:This is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended.
另请参见:http :
//nl3.php.net/manual/zh/function.mysql-set-
charset.php
使用以下命令检查当前连接的字符集:
echo mysql_client_encoding($conn);
另请参见:http :
//nl3.php.net/manual/en/function.mysql-client-
encoding.php
如果您已完成这些操作并在表中添加了奇怪的字符,您将看到它显示正确。



