PHPget_magic_quotes_gpc and addslashes usage

Source: Internet
Author: User
PHPget_magic_quotes_gpc and addslashes usage
This judgment condition is often encountered in the code.

  1. If (! Get_magic_quotes_gpc ())
  2. {
  3. $ P = addslashes ($ name); // $ name is used to obtain a user input value.
  4. }

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.