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.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|