php 页面不显示阿拉伯文文本
我有一个 PHP 页面,我试图在其中显示阿拉伯文本,但它显示了。
在 MySQL 数据库中,我成功存储了阿拉伯文本。
我使用以下代码连接到数据库:
function connect(){
$this->dbLink = mysql_connect($this->dbHost,$this->dbUser,$this->dbPass);
if(!$this->dbLink) die("Could not connect to database. " . mysql_error());
mysql_select_db($this->dbName);
mysql_set_charset("utf8", $this->dbLink);
}
并在 PHP 页面中使用以下标头:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
但仍然没有成功。
谢谢你的帮助。
I have a PHP page where I am trying to display Arabic text but its showing.
In MySQL database I'm storing arabic text successfully.
I'm using the following code to connect to the database :
function connect(){
$this->dbLink = mysql_connect($this->dbHost,$this->dbUser,$this->dbPass);
if(!$this->dbLink) die("Could not connect to database. " . mysql_error());
mysql_select_db($this->dbName);
mysql_set_charset("utf8", $this->dbLink);
}
And using the following header in the PHP page :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
But still no success.
Thanks for helping.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用此元代码:
并且请检查 mysql 列的字符类型..
查看 this
You can use this meta code:
And please check mysql column's character type..
Look to this
检查文件编码,应该是UTF-8,您可以在查询文本之前尝试运行以下查询:
check the file encoding, it should be UTF-8, and you can try to run the following query before querying the text:
除了元部分中设置的标头之外,请检查 php.ini 中的 default_charset 设置。如果您自己设置内容类型标头或与您的内容类型元信息相对应,default_charset 应该为空。
Addtional to the headers set in the meta section, check your default_charset setting in the php.ini. default_charset should be empty if you set content type header by your own or correspond with your content-type meta information.
您设置一个告诉浏览器使用 ISO-8859-1 的 META 标记 (
;
),适用于基于拉丁语的脚本,但肯定不是阿拉伯语。还要确保您在所有位置都有 UTF-8:
You set a META-tag that tells the browser to use ISO-8859-1 (
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
), which is for latin-based scripts, but surely not Arabic.Also make sure you have UTF-8 at all places:
您是否尝试过将连接设置为使用UTF-8(使用mysql_set_charset)?
Have you tried setting the connection to use UTF-8 (with mysql_set_charset)?
尝试在 Mysql 连接之后将这两行添加到 php 脚本中
mysql_query("SET NAMES cp1256");
mysql_query("设置字符集cp1256");
Try to add this two lines to your php script after the Mysql connection
mysql_query("SET NAMES cp1256");
mysql_query("set character set cp1256");