gpt4 book ai didi

php - 反向 htmlspecialchars

转载 作者:IT王子 更新时间:2023-10-29 01:06:50 27 4
gpt4 key购买 nike

这似乎是一个简单的问题,但我在文件中找不到它。

如何扭转 htmlspecialchars 的影响?

我试过这样的:

$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$html = strtr ($html, $trans_tbl);

但是没有用。有没有简单的方法可以做到这一点?

最佳答案

使用 htmlspecialchars_decode()

<?php
$str = "<p>this -&gt; &quot;</p>\n";

echo htmlspecialchars_decode($str);

// note that here the quotes aren't converted
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>

引用 - PHP Official Doc

关于php - 反向 htmlspecialchars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11257232/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com