skip to Main Content

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


  1. You can check on your server setting and make error reporting off.May be it will works

    Login or Signup to reply.
  2. 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:

    • error reporting
    • php settings
    • php.ini

    Usually you’ll see some options like:

    • show only critical errors and omit notices
    • log errors to a log file
    • disable all error messages and logging

    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

    1. php-script
    2. htaccess directives

    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

    <?php 
    error_reporting(0);
    <?>
    

    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

    # supress php errors
    php_flag display_startup_errors off
    php_flag display_errors off
    php_flag html_errors off
    php_value docref_root 0
    php_value docref_ext 0
    

    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

    <?php phpinfo(); ?>
    

    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!)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search