This article analyzes the difference between addslashes and mysql_escape_string in PHP with an example. Share it with everyone for your reference, the details are as follows:
1.The meaning of the two is basically the same when inserting data. The only difference is that addslashes
convert " '" to " ' '" when magic_quotes_sybase=on
Convert " '" to " '" when magic_quotes_sybase=off
and mysql_escape_string always converts " '" to " '"
2.mysql_escape_string will be abandoned in php6, so it is best to avoid using it.
And it’s best to use the object-oriented mysqli::real_escape_string,
If you have to use process-oriented, you can use mysql_real_escape_string
Readers who are interested in more PHP-related content can check out the special topic of this site: "PHP Data Structure and Algorithm" Tutorial", "Summary of PHP operations and operator usage", "Summary of PHP network programming skills", "Introduction to PHP basic syntax tutorial", "Summary of PHP operating office document skills (including word, excel, access, ppt)", "php Summary of Date and Time Usage", "Introduction Tutorial on PHP Object-Oriented Programming", "Summary of PHP String Usage", "Introduction Tutorial on PHP+MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
Hope this article The above will be helpful to everyone in PHP programming.
The above has introduced the analysis of the difference between addslashes and mysql_escape_string in PHP, including the contents of slashes and string. I hope it will be helpful to friends who are interested in PHP tutorials.