Ray*_* S. 32 php htmlspecialchars
这似乎是一个简单的问题,但我无法在档案中找到它.
如何扭转htmlspecialchars的影响?
我试过这样的事情:
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$html = strtr ($html, $trans_tbl);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.有一个简单的方法来做到这一点?
swa*_*esh 72
使用 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);
?>
Run Code Online (Sandbox Code Playgroud)
参考 - PHP官方文档