How to change magic_quotes_off in PHP?


I am new in PHP but I read in many pages that is a recommendation to turn off this setting, and my actual phpinfo() says that it is ON.

How i can change to OFF? What is a .htaccess file? How I can change this setting?

I read in php manuals and many links, but I don't understand nothing! Any simple form?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
It is in 'php.ini' .  It can also be set in '.htaccess' if you are running under Apache.  It can not be changed by your code because it is a value that needs to be known before your page is run.

'.htaccess' is a file that can be used with an Apache web server to set some directives in the directories where they need to be used instead of in the master file for all directories.
joyacv2Author Commented:

But I don't understand the link, how i can access the .htaccess file and change the setting?

The link says: "f the magic_quotes_sybase directive is also ON it will completely override magic_quotes_gpc", what exactly this means? Is correct for Off too?
Dave BaldwinFixer of ProblemsCommented:
The page on tells you what it means.  The first thing to know is that it is not something critical.  About half of my web sites have it on and half have it off and I can still run the same programs on them.  It will not stop you from running PHP programs.

Where is your web site?  Are you on an Apache web server?  Shared hosting?
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

joyacv2Author Commented:
Local Apache web server
Ray PaseurCommented:
In my installations of PHP I can make my own .htaccess files and my own PHP.INI files, so I turn off the things I do not want.  And I'm with DaveBaldwin on this issue - you need to write code that can tolerate either condition.  So in the initialization of all my pages, I have something like this to remove the adverse effects of magic_quotes.

foreach ($_REQUEST as $k => $v)
    $_REQUEST[$k] = stripslashes($v);

Not very scientific, but it has never failed me yet ;-)
joyacv2Author Commented:

But how i can change the setting directly with .htaccess?
Dave BaldwinFixer of ProblemsCommented:
joyacv2Author Commented:
But where i enter this line of code?
Dave BaldwinFixer of ProblemsCommented:
In your '.htaccess' file which goes in the root directory of your web site.  You will probably have to create the file because it is only used when you need to tell Apache and PHP about something different than the normal configuration.
joyacv2Author Commented:
Can you give me a brief guide on where and how create this file?
Dave BaldwinFixer of ProblemsCommented:
I thought I just did with the links to the PHP and Apache pages.  In the simplest version, you create a file called '.htaccess', put that line in it, and save it in the root directory of your web site.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.