我已经完成了我能想到的一切,但是在这个网页上没有正确显示特殊字符.
例如,在数据库中它是:
但在网站上它是:
Nouveaux R�alistes
这是我检查过的一切……
数据库设置为UTF-8:
该页面是用NetBeans编写的,文档编码设置为UTF-8:
页眉声明UTF-8:
元字符集设置为UTF-8:
我甚至在我的.htacess中添加了以下行:
我觉得我已经尝试了一切,但它仍然无法运作. (我甚至在PHP中尝试过htmlspecialchars和htmlentities,但页面甚至没有呈现!)
UPDATE
根据要求,这是我正在使用的代码:
class Exhibition {
public $exhibitionDetails;
public function __construct(Database $db,$exhibitionID){
$this->_db = $db;
$params['ExhibitionID'] = $exhibitionID;
$STH = $this->_db->prepare("SELECT *
FROM Exhibition
INNER JOIN Schedule
ON Exhibition.ExhibitionID = Schedule.ExhibitionID
WHERE Schedule.Visible = 1
AND Exhibition.ExhibitionID = :ExhibitionID;");
$STH->execute($params);
$this->exhibitionDetails = $STH->fetchAll(PDO::FETCH_ASSOC);
}
}
和…
try {
$db = new Database(SITE_ROOT."/../");
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$exhibition = new Exhibition($db,$_GET['id']);
} catch (PDOException $e) {
echo "
最后……
PHP echo $exhibition->exhibitionDetails[0]["Desc"]; ?>
最佳答案
原文链接:https://www.f2er.com/mysql/433141.html