HTML用PHP编码 [英] Html encode in PHP
本文介绍了HTML用PHP编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PHP中使用HTML编码最简单的方法是什么?
What is the easiest way to Html encode in PHP?
推荐答案
通过编码,您的意思是:将所有适用的字符转换为HTML实体?
By encode, do you mean: Convert all applicable characters to HTML entities?
htmlspecialchars
或
htmlentities
htmlspecialchars
or
htmlentities
如果要删除所有HTML标记,也可以使用strip_tags:
You can also use strip_tags if you want to remove all HTML tags :
注意:这不会阻止所有 XSS攻击
Note: this will NOT stop all XSS attacks
这篇关于HTML用PHP编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文