微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – mysql_real_escape_string和addslash有什么区别?

mysql_real_escape_string和addslash都用于在数据库查询之前转义数据,所以有什么区别? (这个问题不是关于参数化查询/ PDO / MysqLi)

string MysqL_real_escape_string ( string $unescaped_string [,resource $link_identifier ] )
MysqL_real_escape_string() calls MySQL‘s library function MysqL_real_escape_string,which prepends backslashes to the following characters: \x00,\n,\r,\,‘,” and \x1a.

string addslashes ( string $str )
Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote (‘),double quote (“),backslash (\) and NUL (the NULL byte).

它们影响不同的角色. MysqL_real_escape_string是特定于MysqL的. Addslashes只是一个通用的功能,可能适用于其他的东西以及MysqL.

原文地址:https://www.jb51.cc/php/131919.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐