問題描述
MySql 數據庫使用 utf-8 編碼并且數據存儲正確.我使用 set_name utf8 查詢來確保調用的數據是 utf-8 編碼的.只要標題字符集是 utf-8,數據庫中的所有變量都可以正常工作,但靜態 html 字符不能正常工作.當我將標題字符集設置為 ISO-8859-9 變量時,顯示不同,而 html 字符工作正常.有人可以幫助我嗎?utf8 編碼:http://oi48.tinypic.com/289kje1.jpg html 標簽顯示有問題values.but 來自數據庫的 php 數據(綠色的,例如 a?i?ler)是可以的.ISO 編碼 http://oi50.tinypic.com/287n2ph.jpg 這次html沒問題但是php數據顯示錯誤.
MySql database uses utf-8 encoding and data are stored correctly.I use set_name utf8 query to make sure the data called are utf-8 encoded.all variables from database works fine as long as the header charset is utf-8,but the static html characters do not work properly.When i set header charset to ISO-8859-9 variables are displayed differenly while html characters work ok.can anyone help me? Utf8 encoding: http://oi48.tinypic.com/289kje1.jpg html tags have problem displaying values.but php data(green ones e.g. a?i?ler) that come from database is ok.ISO encoding http://oi50.tinypic.com/287n2ph.jpg this time the html is ok but php data are displayed wrong.
<?php
header('Content-Type: text/html; charset=ISO-8859-9');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>noname</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
推薦答案
您可以嘗試在文件頂部顯式添加內容類型,如下所示
You can try explicitly adding content type at the top of your file as below
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
并從您的代碼中刪除以下內容..
and remove the below from your code..
header('Content-Type: text/html; charset=ISO-8859-9');
更新:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php echo "for example ? and ? "; ?>
</body>
</html>
上面的代碼給了我下面的輸出:
The above code gives me the below output:
這篇關于土耳其語字符顯示不正確的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!