它在我的旧服务器上工作正常,但当我在新服务器上移动时,我正面临着这个问题。
当我尝试从MySQL获取阿拉伯数据时,我得到了这些字符。 آØμÙØةأرØ||Š³Øية
但是当我直接在我的页面上写阿拉伯语内容时,它显示完美。
我已经尝试过这些,但面临同样的问题。
<?php @mysql_query("set global character_set_results=utf8");
@mysql_query("SET NAMES utf8;");
@mysql_query("SET CHARACTER_SET utf8;");?>
答案 0 :(得分:0)
在HTML中添加此内容。
<head>
<meta charset="utf-8">
</head>
答案 1 :(得分:0)
您的mysql设置似乎没问题。您可以使用以下元代码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
进一步检查mysql列的字符类型。字符集应该是'utf8'
我希望你已经保存了没有BOM的php文件吗?如果不是,请检查here。
修改强> 1。用以下三行代码替换下面一行:
mysql_query("SET character_set_results = 'utf8'");
mysql_query("character_set_client = 'utf8'");
mysql_query("character_set_connection = 'utf8'");
mysql_query("character_set_database = 'utf8'");
2. 设置文档标题:
header("content-type: text/html; charset=utf-8");
就像这样:
<?php
// Send a raw HTTP header
header ('Content-Type: text/html; charset=UTF-8');
// Declare encoding META tag, it causes browser to load the UTF-8 charset before displaying the page.
echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />';
// Right to Left issue
echo '<body dir="rtl">';
?>
您可以从here应用更多选项作为解决方案。我希望上面的解释能解决你的问题。