【发布时间】:2014-10-03 21:36:56
【问题描述】:
我的结果有问题。 请有人能告诉我我做错了什么。
我在 mysql 字段中有这个文本:
----------------------------------------------------
text “strange double quotes” "normal double quotes"
----------------------------------------------------
在文本区域中,我从数据库中回显字符串
<textarea>
$string = stripslashes(htmlspecialchars_decode($string,ENT_QUOTES));
echo htmlspecialchars($string);
</textarea>
然后崩溃(不显示任何内容)。
但如果我只有普通文本或普通引号:
"this is a correct text with quotes"
这行得通。
你知道我需要做什么吗?
TY
【问题讨论】:
-
这里
stripslashes和htmlspecialchars_decode的目的是什么?为了确保数据安全,您只需要htmlspecialchars(尽管在该调用中指定字符集是个好主意)。 -
您遇到的崩溃的性质是什么?你得到了什么错误,或者是什么让你相信这是一个崩溃?