Why does WordPress keep showing me error messages?

I'm trying to hide error messages on a WordPress installation on a shared hosting. I added the following code to my config.

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

This is pretty much what I find in any article regarding this topic. However, it doesn't work. I keep getting error messages. What could be the reason it isn't working for me?


A little update. One error I sometimes get is a notice. When I keep all these three lines and put error_reporting to 0 as suggested in the answers, I still get the notice error.

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

However, when I comment the last 3 lines, the notice disappears:

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

Does that make any sense to anyone? What's happening here?

Topic wp-debug debug errors Wordpress

Category Web


If your hosting php.ini is properly configured, is not necessary to use ini_set() in your wp-config.php when you are defining WP_DEBUG.

What is WP_DEBUG? It's a constant used in WP to determine what error notice settings to apply. When WP loads, one of the functions that is run on every load is wp_debug_mode(). I highly suggest you review what it does so you know why you originarily do not need to use ini_set() - because it's already being done in wp_debug_mode(). So what you're doing by adding this to your wp-config.php is the equivalent of flipping the switch on/off/on/off over and over.

When WP_DEBUG is set to true, it sets error_reporting( E_ALL ). Otherwise, error_reporting() is set to a lesser value. You should not manually set this to 0 unless you know what you're doing - otherwise, you're shutting off all error reporting, which will make it hard when you actually need to debug something but forgot that you turned off all notices. Unless you really have a need to do so, just let WP handle setting the error_reporting() value.

Next, when WP_DEBUG is true, it handles the display of errors based on the WP_DEBUG_DISPLAY value. If it's true, then ini_set() is run to set 'display_errors' to "1", which will display errors on the screen. If WP_DEBUG_DISPLAY is set to false, it will set 'display_errors' to "0" which will suppress display of any errors.

I hope this didn't confuse the issue, and I hope that you can see why the last set you had (where all but WP_DEBUG was commented out) suppressed the messages.

If you want error messages turned off, just set WP_DEBUG and WP_DEBUG_DISPLAY to false, and get rid of the ini_set() lines you have.


You shoud use

ini_set('error_reporting', 0 );

instead of:

ini_set('error_reporting', E_ALL );

because E_ALL tell to show every error.


I believe that this line

ini_set('error_reporting', E_ALL );

will override other error settings. Will display all errors, even 'benign' ones, to the screen and error log file.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.