Jump to content

Archived

This topic is now archived and is closed to further replies.

lucerias

The meaning of get_magic_quotes_gpc()

Recommended Posts

Can anyone explain get_magic_quotes_gpc() to me? i have gone through the definition of PHP from site but can't really get the point. Thank you.

Share this post


Link to post
Share on other sites
In short:
Returns the current configuration setting of magic_quotes_gpc which is set in the php.ini

So if the magic_quotes_gpc is set to 1 or TRUE the get_magic_quotes_gpc function will return true. If magic_quotes_gpc is set to 0 or FALSE get_magic_quotes_gpc function will return false.

magic_quotes escapes quotes from within a string which is PHPs way of making user input safe for you to use.

Share this post


Link to post
Share on other sites
A semantic correction: get_magic_quotes_gpc() returns 0 or 1.

Share this post


Link to post
Share on other sites
Thanks guys, i know that it returns bool true or false but what is this config about? I am not asking on or off but the purpose of magic_quotes_gpc() itself.

Share this post


Link to post
Share on other sites
It was a safety feature, originally designed to help new coders starting to learn PHP. Because PHP learning curve is some what easy compared to Perl or other higher level languages you end up with many people who want just the end result, they don't care about learning how to set a good coding standard that they should follow. This results in thousands of hacked script floating around the Internet that are dangerous. So my hosts started implementing magic_quotes so as to protect their servers from all of these dangerous scripts! But this can cause even more problems, if you don't check if magic_quotes is on and then you addslashes to already escaped string. Adding slashes like anything else you do, should be done in a selective way, because it senseless to addslashes to a variable value that doesn't need it.

me!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.