Htmlentities vs addslashes vs mysqli_real_escape_string

前端 未结 7 1103
悲哀的现实
悲哀的现实 2020-12-18 03:04

I\'ve been doing some reading on securing PHP applications, and it seems to me that mysqli_real_escape_string is the correct function to use when inserting data

7条回答
  •  猫巷女王i
    2020-12-18 03:29

    yes, use the mysqli_real_escape_string or a library like PDO on all user input. When echoing back, I use htmlentities with ENT_QUOTES as the second parameter, as it escapes all applicable characters to their html entities, including quotes.

提交回复
热议问题