Do I need to escape data to protect against SQL injection when using bind_param() on MySQLi?(在 MySQLi 上使用 bind_param() 时是否需要转义数据以防止 SQL 注入?)
问题描述
正如标题所说,我在使用 bind_param() 时是否必须转义用户输入,还是在内部完成?
As the title says, do I have to escape user input when using bind_param() or is that done internally?
谢谢.
推荐答案
不需要,绑定参数时不需要转义数据以防止 SQL 注入.
No, you do not need to escape data to protect against SQL injection when binding parameters.
但这并不能免除您验证所述数据的责任.
This does not absolve you from validating said data though.
绑定参数时,不执行转义(内部或其他方式).使用参数占位符准备 SQL 语句,并在执行时传递这些参数的值.
When binding parameters, there is no escaping performed (internally or otherwise). An SQL statement is prepared with parameter placeholders and values for these are passed at execution time.
数据库知道什么是参数并相应地处理它们,而不是 SQL 值插值.
The database knows what parameters are and treats them accordingly as opposed to SQL value interpolation.
这篇关于在 MySQLi 上使用 bind_param() 时是否需要转义数据以防止 SQL 注入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 MySQLi 上使用 bind_param() 时是否需要转义数据以


- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01