apache 如何使用php和sql server在网页中显示阿拉伯字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1210863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display arabic characters in web page using php and sql server
提问by
How can I display Arabic characters in web page using php and sql server? The Arabic data is stored in the database (sql server). Now I want to use php to display that data on the web page. How can I do this?
如何使用php和sql server在网页中显示阿拉伯字符?阿拉伯语数据存储在数据库(sql server)中。现在我想使用 php 在网页上显示该数据。我怎样才能做到这一点?
回答by TigerTiger
Some SO archive may help you some ideas -
一些 SO 档案可能会帮助你一些想法 -
Storing and displaying unicode string (??????) using PHP and MySQL
使用 PHP 和 MySQL 存储和显示 unicode 字符串 (??????)
Arabic text displaying in webapp without db changes
what is the best method to build "multilingual" script in php?
回答by eanimator
Note: its php/mysql based example:
注意:其基于 php/mysql 的示例:
- Before you can store Arabic content
in a database, you need to create a
table. The following example
demonstrates the
CREATEsyntax - You need to make sure your browser supports the character set.
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
- 在将阿拉伯语内容存储在数据库中之前,您需要创建一个表。以下示例演示了
CREATE语法 - 您需要确保您的浏览器支持该字符集。
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
SQL Statements:
SQL 语句:
//assumed : connection to the database is open
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES 'utf8'");
// select records
mysql_query("SELECT * FROM en_authors");
回答by nafsin vk
The official solution for Unicode in mssql with php
mssql with php Unicode 官方解决方案
$serverName = "MyServer";
$connectionInfo = array( "Database"=>"AdventureWorks", "CharacterSet" => "UTF-8");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
use this in your connection code,
get more support on utf 8 issue on
http://msdn.microsoft.com/en-us/library/cc626307.aspx
在您的连接代码中使用它,
在http://msdn.microsoft.com/en-us/library/cc626307.aspx上获得有关 utf 8 问题的更多支持

