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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:00:10  来源:igfitidea点击:

How to display arabic characters in web page using php and sql server

phpsql-serverapache

提问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 eanimator

Note: its php/mysql based example:

注意:其基于 php/mysql 的示例:

  1. Before you can store Arabic content in a database, you need to create a table. The following example demonstrates the CREATEsyntax
  2. You need to make sure your browser supports the character set. <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
  1. 在将阿拉伯语内容存储在数据库中之前,您需要创建一个表。以下示例演示了CREATE语法
  2. 您需要确保您的浏览器支持该字符集。 <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 问题的更多支持