The example in this article describes the analysis of the security principles of using addslashes function escaping in PHP. Share it with everyone for your reference. The specific analysis is as follows:
Let’s first take a look at the prototype of addslashes_deep in ECshop
I hope this article will be helpful to everyone’s PHP programming design.
addslashes -- Use backslashes to quote strings
string addslashes ( string str )
Returns a string that needs to be preceded by certain characters for database query statements, etc. Backslash added. These characters are single quote ('), double quote ("), backslash (\) and NUL (NULL character).
An example of using addslashes() is when you want to enter data into a database For example, if you insert the name O'reilly into the database, you need to escape it. Most databases use \ as the escape character: O\'reilly. This will put the data into the database without inserting it. Extra \. When the PHP directive magic_quotes_sybase is set to on, it means that ' will be escaped when inserting '
By default, the PHP directive magic_quotes_gpc is on, which is mainly used for all GET, POST and COOKIE data automatically run addslashes(). Do not use addslashes() on strings that have been escaped by magic_quotes_gpc, because this will cause double-level escaping. You can use the function get_magic_quotes_gpc() to detect this situation.
See if you need to dequote a string escaped using addcslashes. You can use the stripcslashes function to decode it