I’ve tried setting WP_DEBUG and WP_DEBUG_DISPLAY to false. After that, I’ve tried following in wp-config:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Still, PHP warnings and notices are shown on the frontend. I’ve also checked with ini_get
before and after setting ini vars, looks like it’s properly set everything, but notices and warnings are still shown.
If I clone website locally or to different host, everything works properly, ie. notices and warnings are hidden. Is there anything else I could try?
2
Answers
You can check on your server setting and make error reporting off.May be it will works
This is not a wordpress issue but tied to your server setup and php configuration.
Option 1: Make sure error output is disabled on server side
If you have access to your hosting admin area (… maybe something like plesk or a custom admin ui):
search for something like:
Usually you’ll see some options like:
Nothing?
Contact the hosting provider’s support (or web admin), where to set this configuration. (This should actually be default in every hosting environment – even with most basic shared hosting setups).
Option 2: Dirty Hacks/overridung
2.1 If your theme has a global header template part/include like "header.php" that’s included/required before any html output, you could add a php function like
This should work pretty much everywhere – still a temporary solution. If you’re using a regularly updated theme – this hack will be deleted after every update.
2.2 htaccess directive
Jeff Starr has elaborated on this approach
If you have access to a .htaccess file you might try to add these directives
Actually … not a valid solution either.
.htaccess will only work if you’re on an apache driven webserver (even then – based on your apache version, specific compiled version, configuration … quite a lot of snippets just won’t work).
Maybe your website isn’t even hosted on an apache webserver but instead nginx or even IIS … etc.
Before checking other options, you might check your current webserver/php setup by
uploading a test.php file with this content to your root dir
Delete this file after checking your setup. In particular interesting wether you’re on apache or nginx etc.
Conclusion
Make sure to disable error handling on the server side.
So stick with proper server configs and don’t waste too much time with any hacks! (… we all need them now and then!)