PHPget_magic_quotes_gpc and addslashes usage
This judgment condition is often encountered in the code.
- If (! Get_magic_quotes_gpc ())
- {
- $ P = addslashes ($ name); // $ name is used to obtain a user input value.
- }
First, let's take a look at the functions of get_magic_quotes_gpc: Magic_quotes_gpc: whether to automatically add a backslash (and escape) before the '(single quotation mark) "(double quotation mark) (backslash) in the data sent by GPC (get, post, cookie) Get_magic_quotes_gpc () is to check whether this item is set. if it has been set, true is returned. if it is not set, false is returned. We need to manually escape some special characters when we do not set them, as mentioned above, ', ", these three. If you manually escape special characters? The addslashes ('content') method is used. the parameter is a string to be escaped.
Therefore, the above code first checks whether the system automatically adds a backslash before a special character. if not, we need to call the addslashes () method () to escape special characters in user input. Php technical problemsWelcome to group discussion:256271784, Verification code:Cxy. If you do not write the verification code, it will not pass.
|