wp

How to disable PHP error output in WordPress

PHP warnings and notifications help developers in tweaking the website and finding errors. However, it looks extremely unprofessional when these errors are displayed on the homepage of your website and visible to all visitors.

In this article, we will show you how you can hide and disable the display of PHP errors on your WordPress site.

When and why disable PHP errors on WordPress?

PHP errors that you may see at the top of a website page are usually warnings or notifications. These are a far cry from Internal Server Error, Syntax Error, or Fatal Error, which stop yours completely.

Warnings and notifications are a type of error that do not stop WordPress from working and loading.

The purpose of these warnings is to give hints to the developer when debugging the code. Plugin and theme developers use this useful information in an attempt to eliminate all bugs and errors in the final version.

But if you are not a developer, these PHP bug warnings should be hidden.

How to disable displaying PHP errors in WordPress

To accomplish this task, we will need to edit the wp-config.php file. Inside the wp-config.php file, which is in the root of your site, find the line of code:
define('WP_DEBUG', true);
It is quite possible that you have this parameter set to FALSE, in which case you will find the line of code:
define('WP_DEBUG', false);
Either way, you need to replace this line with the following code:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Don’t forget to save your changes and upload the wp-config.php file back to your site. Now you can log into your site and make sure all PHP errors and warnings are gone.

How to enable the display of PHP errors in WordPress

If you are developing on a local server or on a test site, then it makes sense to do the opposite and force all PHP warnings and errors to be displayed. To do this, open the wp-config.php file again and replace the code above with this one:
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
This code will command WordPress to display all kinds of PHP errors, warnings and errors again.

Leave A Comment

Complimentary SEO Audit