加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – mysql_real_escape_string和addslash有什么区别?

发布时间:2020-12-13 16:39:28 所属栏目:PHP教程 来源:网络整理
导读:mysql_real_escape_string和addslash都用于在数据库查询之前转义数据,所以有什么区别? (这个问题不是关于参数化查询/ PDO / mysqli) string mysql_real_escape_string ( string $unescaped_string [,resource $link_identifier ] ) mysql_real_escape_strin
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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读