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 标签,例如,如果用户放置一个 html 标签,例如<br>或<hr>不显示水平行或换行符,就按原样显示(打印输出<br> or <hr>:)
<br>
<hr>
<br> or <hr>
您应该使用它htmlspecialchars()来防止这种情况。这也将防止XSS 攻击。
htmlspecialchars()
http://codepad.viper-7.com/w5U8qs