反向htmlspecialchars [英] reverse htmlspecialchars
本文介绍了反向htmlspecialchars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎是一个简单的问题,但我无法在档案中找到它.
this may seem like a simple problem but I couldn't find it in the archives.
如何逆转htmlspecialchars的影响?
how does one reverse the effects of htmlspecialchars?
我尝试过这样的事情:
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$html = strtr ($html, $trans_tbl);
但是没有用.有没有简单的方法可以做到这一点?
but it didn't work. is there a simple way to do this?
推荐答案
使用htmlspecialchars_decode()
<?php
$str = "<p>this -> "</p>\n";
echo htmlspecialchars_decode($str);
// note that here the quotes aren't converted
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>
参考- PHP正式文档
这篇关于反向htmlspecialchars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文