when to use htmlspecialchars() function?

前端 未结 4 1994
自闭症患者
自闭症患者 2020-11-28 09:06

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?

4条回答
  •  执笔经年
    2020-11-28 09:25

    You should only call this method when echoing the data into 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.

提交回复
热议问题