Home Guides Glossary

Disable Magic Quotes

Magic Quotes is a process that automatically escapes incoming data to the PHP script. However, it can cause issues for your website and you might need to disable it.

Since the release of PHP 5.3.0, this feature has been deprecated.

There are a few ways you can disable Magic Quotes:

Disabling Magic Quotes Server Side via php5.ini

Add this code to your php5.ini file:
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off

If the hosting account does not have a php5.ini file, you have to add one.

For this change to take effect, you might need to stop your account's PHP process. For more information, see Manage system process (Linux).

Disabling Magic Quotes at Runtime

Place code at top of the .php file so it executes when the file runs:

<?php
if (get_magic_quotes_gpc()) {
function magicQuotes_awStripslashes(&$value, $key) {$value = stripslashes($value);}
$gpc = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
array_walk_recursive($gpc, 'magicQuotes_awStripslashes');
}
?>

The magic_quotes_gpc directive may only be disabled at the system level, and not at runtime.

For more information regarding Magic Quotes please refer to php.net.

Domain Registration

Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. We have everything you need to get online with your new domain.

Website Builder

Build an amazing website in just under an hour with Website Builder. Take advantage of designs created just for your industry and then customize them to reflect your one-of-a-kind idea.

Website Security

Protect your website and keep customers safe. Your comprehensive Website Security solution. Get peace of mind by securing your websites.

cPanel Hosting

Everything needed to give your website the high-performance home it deserves.  Protect transactions and secure your customer's data with a SSL Certificate
Copyright © 2005 - 2024.  All rights reserved.  Privacy Policy