我的数据库包含以下数据:
<b><a href="[LINK]">你</a></b> 在活动中已确定席位<b><a href="[LINK]">[TITLE]</a></b><br>
当我显示它时,它显示为:
<b> <a href="[LINK]">You</a></b> have a confirmed seat in the event <b><a href="[LINK]">[TIT
文本被破坏,并且还显示了 html 标签
我试过 html_entity_decode()
请帮忙谢谢
只需使用htmlspecialchars_decode
htmlspecialchars_decode( '[...]', ENT_QUOTES );
Try using htmlspecialchars() while saving data to database and htmlspecialchars_decode() while displaying data to browser.
Hope this help you.
function cleanMyDirtyData( $dirty_dirty_data ){
return mysql_real_escape_string( htmlentities( $dirty_dirty_data, ENT_QUOTES,'UTF-8' ) );
}
在将数据写入数据库之前,请尝试使用此功能。
无论您从服务器获得什么响应,只需将其传递给 javascript。
在 Javascript 中,
var p = document.getElementById('pID');
p.textContent = "Your text from backend here";
在 jQuery 中,
$('#idName').text("Your text from backend here");
我不知道是否可以使用 PHP 来完成,因为我不在那个领域。