php 页面不显示阿拉伯文文本

发布于 2024-12-01 21:15:45 字数 553 浏览 8 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

星星的轨迹 2024-12-08 21:15:45

您可以使用此元代码:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

并且请检查 mysql 列的字符类型..

查看 this

You can use this meta code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

And please check mysql column's character type..

Look to this

梦罢 2024-12-08 21:15:45

检查文件编码,应该是UTF-8,您可以在查询文本之前尝试运行以下查询:

mysql_query("SET NAMES UTF8");

check the file encoding, it should be UTF-8, and you can try to run the following query before querying the text:

mysql_query("SET NAMES UTF8");
涙—继续流 2024-12-08 21:15:45

除了元部分中设置的标头之外,请检查 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.

献世佛 2024-12-08 21:15:45

您设置一个告诉浏览器使用 ISO-8859-1 的 META 标记 (;),适用于基于拉丁语的脚本,但肯定不是阿拉伯语。

还要确保您在所有位置都有 UTF-8:

  • 数据库列、
  • 数据库连接(您已经拥有它)、
  • 网站(通过 HTTP 标头或元标记,您不需要两者,也不需要需要第二个 META 标签,如上所述……)

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:

  • the DB-column
  • the DB-connection (you already have it)
  • the website (via HTTP-header OR META-tag, you don't need both, and you don't need a second META-tag, as stated above…)
银河中√捞星星 2024-12-08 21:15:45

您是否尝试过将连接设置为使用UTF-8(使用mysql_set_charset)?

Have you tried setting the connection to use UTF-8 (with mysql_set_charset)?

稳稳的幸福 2024-12-08 21:15:45

尝试在 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");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文