All Collections
PHP
PHP Errors
How to Hide Errors and Warnings on Your Website
How to Hide Errors and Warnings on Your Website

How to hide PHP errors from your website, using hPanel, .htaccess, and configuration files

Updated over a week ago

While displaying PHP Errors and warnings can be useful for debugging your website, you may not want to have them on all the time. These messages can be turned off in several ways. Let's go over them in detail:

Option 1 - WordPress Configuration File

If your website is WordPress-based, go to the File Manager and open your public_html/wp-config.php file. Next, check if any of these lines are present:

define('WP_DEBUG', true);
define('WP_DEBUG', false);

If either one of them or both are present, remove them. Next, add the following code:

ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

That's it, now PHP errors will not be displayed on your WordPress website 😊


Option 2 - .htaccess File

Go to the File Manager and open your public_html/.htaccess file. If there is no .htaccess file, you can create it. Next, add the following line:

php_flag display_errors off

Save the changes and now the PHP errors will no longer be displayed on the website.


Option 3 - .php File

If you want to hide PHP errors from a single session or page of your website, go to the File Manager and open the desired page's .php file. Next, add the following line:

error_reporting(0);

Save the changes, and now the PHP errors will be hidden in this particular page.

Did this answer your question?