昨天我將我的網站移動到一個新的託管服務器,並且遇到了Unicode文本問題。這是什麼導致Unicode顯示爲垃圾字符?
在舊的託管包同樣的腳本工作正常,並在新的託管,統一顯示如下:
在這兩個託管這是測試代碼,我用:
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
</head>
<body>
<?
$host = '';
$user = '';
$pass = '';
$db = '';
$con = mysql_connect($host , $user , $pass) or die ("Connection could not established." .mysql_error());
mysql_select_db($db , $con) or die ("Colud not select database" . mysql_error());
$sql = "select * from news_line where status='enable' order by date DESC";
$res = mysql_query($sql);
while($dat=mysql_fetch_array($res)){
echo $dat['news'];
}
mysql_close($con);
?>
</body>
</html>
什麼可能會導致這種行爲在新的託管?
您正在使用的術語「* Unicode的*」,如果它是一個字符編碼。 [這不是。](http://www.joelonsoftware.com/articles/Unicode.html) – Biffen
你爲什麼要用代碼片段編寫php代碼? – Tiger