显示和显示相反&

时间:2011-02-10 14:43:04

标签: php html special-characters html-entities

我在数据库中保存了以下字符串:“cocotte & kekette” 当我查询它并在我的网页上显示PHP时,会显示字符串“cocotte & kekette” 谁能告诉我如何解决这个问题?

2 个答案:

答案 0 :(得分:6)

尝试

html_entity_decode($string);

或者

mb_convert_encoding($string, "HTML-ENTITIES", "UTF-8");

答案 1 :(得分:1)

这意味着您可能已经在数据库中保存了“cocotte& kekette”。如果没有,你就是对字符串进行双重编码。

正确的方法是保存数据库中未编码的数据。这是不可能的,请参阅htmlspecialchars中的$double_encode参数(将其设置为FALSE)。

相关问题