如果问题不在要显示在框架中的文件中,则可能是数据中的问题。我总是尝试用 UTF8 配置 PHP、Apache 和 MySQL。为此,我编辑了一些配置文件。
MySQL: /etc/my.cnf
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
init-connect='SET NAMES utf8'
character-set-client=utf8
character_set_results=utf8
然后:
sudo service mysql restart
PHP: /etc/php.ini
default_charset = "UTF-8"
阿帕奇: /etc/apache2/conf.d/charset
AddDefaultCharset UTF-8
然后:
sudo service apache2 restart
连接到数据库时要考虑的另一件事:
...
$link = mysql_connect(SERVER, USER, PASSWORD);
mysql_set_charset('utf8', $link);
...
您可以使用以下命令查看所有与字符相关的变量:
SHOW VARIABLES LIKE 'c%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
| completion_type | NO_CHAIN |
| concurrent_insert | AUTO |
| connect_timeout | 10 |
+--------------------------+----------------------------+
您必须确保 iframe 标记中显示的页面还具有:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
我希望它有所帮助。