Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想允许用户将 html 写入表单字段但不包括 javascript。是否有简单的代码或库可以做到这一点?
我已经研究过使用 HTML Purifer,但我不太确定如何将其配置为以我正在寻找的方式运行。我想我必须指定我允许进入 HTML.allowed 的所有标签。我想我可以列出一个详尽的清单,但如果有更简单的方法,我宁愿这样做。
strip_tags()接受第二个参数$allowable_tags,因此不需要外部库或类,但是是的,您必须允许任何您想要允许的标签。老实说,没有那么多标签。您可能还想禁止<style>
strip_tags()
$allowable_tags
<style>
http://php.net/manual/fr/function.strip-tags.php