Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Turn magic_quotes_gpc Off

This guide shows you how to switch off the old PHP setting called magic_quotes_gpc. It helps when your forms add strange backslashes to text.

Domains and DNS2 min read14 steps

What is magic_quotes_gpc?

PHP is a programming language that runs many websites. magic_quotes_gpc was an old PHP feature. It put a backslash in front of quote marks in form data. So It's became It\'s.

It was meant to protect sites, but it caused many problems. PHP removed it in version 5.4. Newer PHP versions do not have this setting at all.

Tip: This setting is old. If you use PHP 5.4 or newer, you do not need to do anything. The best fix is to move your site to a newer PHP version.

Option 1: use cPanel

cPanel is the control panel where you manage your hosting.

  1. Log in to cPanel.
  2. Open MultiPHP INI Editor or Select PHP Version.
  3. Find the option magic_quotes_gpc. In Select PHP Version it is under Options.
  4. Set it to Off.
  5. Save your change.

If you cannot see the option, your PHP version is too new to have it. Or your host does not show it. You can ask Hostvento support.

Option 2: use a php.ini file

A php.ini file holds settings for PHP.

  1. Open File Manager in cPanel.
  2. Go to the folder of your website, often called public_html.
  3. Look for a file named php.ini. If it does not exist, create one with + File.
  4. Right-click the file and choose Edit.
  5. Add this line.
magic_quotes_gpc = Off

This tells PHP not to add backslashes to form data.

  1. Save the file.

Option 3: use .htaccess

A .htaccess file is a small settings file for the Apache web server. This only works on some setups.

  1. Open .htaccess in the public_html folder. It is a hidden file, so turn on Show Hidden Files in the File Manager settings.
  2. Add this line at the bottom.
php_flag magic_quotes_gpc Off

This switches the setting off for your site.

  1. Save the file and reload your site.
Warning: A wrong line in .htaccess can show a "500 Internal Server Error". Take a copy of the file first. If the error appears, remove your new line.

Quick recap

  • magic_quotes_gpc adds backslashes to quotes in form data.
  • It is old and was removed in PHP 5.4.
  • Switch it off in cPanel, php.ini or .htaccess.
  • The best long-term fix is a newer PHP version.