我有一个 mysql 表,其中包含一些导入的数据,特别是一个值是 Sinn Féin
。
我的数据库使用的字符集是utf8_general_ci
。数据在 phpMyAdmin 中显示良好。在我的网站中,我使用了 PHP header header("Content-type: text/html; charset='utf-8'");
。我有<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
在我的<head>
.
我的数据仍然显示为 Sinn F�in
。我尝试过使用 utf8_decode
,但这没有帮助。我做错了什么?
最佳答案
在mysql_connect()
之后添加以下行:
mysql_query ("SET NAMES utf8");
关于php - mysql/php 的 UTF8 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8616656/