什么时候使用htmlspecialchars()函数? [英] when to use htmlspecialchars() function?

查看:187
本文介绍了什么时候使用htmlspecialchars()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想知道何时才是使用htmlspecialchars()的适当位置.是在将数据插入数据库之前还是从数据库中检索数据时?

Hi I was wondering when is the appropriate place to use htmlspecialchars(). Is it before inserting data to database or when retrieving them from the database?

推荐答案

仅应在将数据回显为HTML时调用此方法.

You should only call this method when echoing the data into HTML.

不要将转义的HTML存储在数据库中;只会使查询更烦人.
数据库应存储您的实际数据,而不是其HTML表示形式.

Don't store escaped HTML in your database; it will just make queries more annoying.
The database should store your actual data, not its HTML representation.

这篇关于什么时候使用htmlspecialchars()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆