when to use htmlspecialchars() function?

前端 未结 4 1992
自闭症患者
自闭症患者 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:15

    Save the exact thing that the user enters into the database. then when displaying it to public, use htmlspecialchars(), so that it offers some xss protection.

提交回复
热议问题