PHP string Format function addslashes ()

Source: Internet
Author: User

1, the use of this function and php.ini in the configuration of the MAGIC_QUOTES_GPC, by default, this configuration is on. Also, this configuration is at a higher level and cannot be modified in the script. Therefore, it is important to detect this configuration situation.

2, in the script, although the MAGIC_QUOTES_GPC can not be configured, but the GET_MAGIC_QUOTES_GPC () function can be detected, return 1, indicating that php.ini is on, otherwise off.

3, MAGIC_QUOTES_GPC is on, the function of the addslashes () function is automatically implemented, for example, when you enter a string containing single quotation marks ('), double quotation marks ("), backslash (\) and click on the Submit button, the symbols are automatically preceded by" \ ". Of course, if you do not submit a string after the text box, you need to implement the effect with a backslash, you must manually use the Addslashes () function.

4. What is the use of a backslash? This should refer to the output of the string. In a script, the output of a string is generally in two ways. One direct echo, and the other inserts into the database. For the previous output, the backslash is useless and must be filtered out with the Stripslashes () function (a bit superfluous), but the backslash is useful for the latter insert into the database.

5, database access to the data do not explore, anyway, you know: with single quotation marks ('), double quotation marks ("), backslash (\) string, only with a backslash in the database, and then read out is the normal data.

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.