mysqli prepared statements and mysqli_real_escape_string

后端 未结 3 808
渐次进展
渐次进展 2020-12-10 16:14

I\'m currently using the mysqli php extension.

Traditionally I have used mysqli_real_escape_string to escape user input. However I am looking at changing over the c

3条回答
  •  隐瞒了意图╮
    2020-12-10 17:00

    Speaking of security, there is no difference between both methods, if you correctly bind or format your variables.

    Binding is just simpler, because it can be used just for any case, while escaping can't (so, you have to cast some variables instead of escaping/quoting).

    Also, bear in mind that no binding nor escaping can make identifier safe. So, if you have to use a field name or operator in your query, you have to use a value, hardcoded in your script.

提交回复
热议问题