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

How to Turn Off PHP Error Reporting

PHP can show error messages on your web pages. This guide shows how to hide them from visitors.

Website Management1 min read13 steps4 screenshots

What is PHP error reporting?

PHP is a language that runs many websites. When a PHP page has a problem, it may print a message on the screen. These messages can look ugly. They may also show file paths that hackers like to see. It is better to hide them on a live site.

Hidden errors are not gone. You can still save them in a log file and read them later.

Take a backup of any file before you change it.

Method 1: MultiPHP INI Editor in cPanel

  1. Log in to cPanel.
  2. Open MultiPHP INI Editor.
  3. Choose Basic Mode and select your domain.
  4. Find display_errors and switch it off.
  5. Click Apply.

Method 2: the .htaccess file

The .htaccess file holds rules for your site.

  1. Open File Manager in cPanel.
    Screenshot: Open File Manager in cPanel.
    Screenshot: Open File Manager in cPanel.
  2. Go to your site folder, often public_html.
  3. Click Settings and tick Show Hidden Files.
    Screenshot: Click Settings and tick Show Hidden Files .
  4. Right-click .htaccess and choose Edit.
    Screenshot: Right-click .htaccess and choose Edit .
  5. Add this line at the bottom.
php_flag display_errors off

This tells PHP not to print errors. On some setups this line causes a 500 error. If so, remove it and use Method 1.

  1. Save the file and reload your site.

Method 3: inside a PHP file

  1. Open your PHP file in the editor.
  2. Add this at the very top, after <?php.
ini_set('display_errors', 0);
error_reporting(0);

The first line hides errors. The second line tells PHP to stop tracking them.

WordPress sites

Open wp-config.php and look for WP_DEBUG. Set it to false.

define('WP_DEBUG', false);
Tip: Turn errors on again while fixing a bug. Turn them off when you finish.

Quick recap

  • Hide errors on live sites for looks and safety.
  • Use MultiPHP INI Editor, .htaccess, or code.
  • In WordPress set WP_DEBUG to false.
  • Back up before editing files.