Get_magic_quotes_gpc () function-PHP source code

Source: Internet
Author: User
Get_magic_quotes_gpc

Script ec (2); script

() Function


In PHP, the () function is a built-in function. The function is used to obtain the value of the magic_quotes_gpc option in the php. ini setting.

Then let's talk about the magic_quotes_gpc options:
If magic_quotes_gpc = On, the PHP parser automatically adds the Escape Character "" to the data from post, get, and cookie to ensure that the data will not cause the program, in particular, database statements may cause fatal errors due to pollution caused by special characters.

In the case of magic_quotes_gpc = On, if the input data has
Single quotation marks ('), double quotation marks ("), backslash (), and NUL (NULL character) are all added with a backslash. These escaping are required. If this option is off, we must call the addslashes function to add escaping to the string.

It is precisely because this option must be On, but there is a conflict between the user's configuration. After this option is deleted in PHP6, all programming needs to be done under magic_quotes_gpc = Off. In such an environment, if user data is not escaped, the consequences are not just program errors. Similarly, it may cause the risk of database injection attacks. Therefore, from now On, you should not rely On this setting to be On any more, so that one day your server will need to be updated to PHP6 and your program will not work properly.

When magic_quotes_gpc = On, function () returns 1
When magic_quotes_gpc = Off, the function () returns 0.

Therefore, we can see that this () function is used to obtain the value of the environment variable magic_quotes_gpc. Since the magic_quotes_gpc option is deleted in PHP6, this function will no longer exist in PHP6.

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.