您好我正在开发一个用户可以提交评论的系统。
问题在于,当我回显转义的字符串时,HTML实体没有显示它们应该显示的内容,但出于某种原因,如果我在页脚中包含版权html权限,它显示并且工作正常吗?
提交的字符串
Why can't i submit this
输出的字符串
Why can't i submit this
转义字符串的函数
function escape($text) {
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}
我用它来确保我的网站使用UTF-8
元标记
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta charset="UTF-8">
的.htaccess
AddDefaultCharset UTF-8
AddCharset UTF-8 .htm .html .css .js .woff
连接
define("DB_SERVER", "mysql:host=myhost;dbname=mydb;charset=utf8");
define("DB_USER", "my user");
define("DB_PASS", "my password");
define("DB_NAME", "my database");
function dbCon() {
try {
$dbCon = new PDO(DB_SERVER, DB_USER, DB_PASS);
} catch (Exception $ex) {
// echo $ex->getMessage();
echo "An error has occured";
}
return $dbCon;
}