How can I stop PHP notices from appearing in wordpress?

后端 未结 6 1104
后悔当初
后悔当初 2020-12-05 04:35

I know about error_reporting(0);, and ini_set(\'display_errors\', false);, but there is a notice appearing in wordpress:

Not

相关标签:
6条回答
  • 2020-12-05 05:07
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     */
    define('WP_DEBUG', false);
    
    // Enable Debug logging to the /wp-content/debug.log file
    define('WP_DEBUG_LOG', false);
    
    // Disable display of errors and warnings 
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors', 0);
    

    What I use and it works with the latest WordPress version.

    0 讨论(0)
  • 2020-12-05 05:18

    In wp-config.php add this line:

    define('WP_DEBUG_DISPLAY', false);
    

    That will enable or disable the display of notices and warnings to the page. There is a fuller description of this option, and some related options, here:

    http://codex.wordpress.org/Debugging_in_WordPress

    0 讨论(0)
  • 2020-12-05 05:21

    Jan 2015 with latest Wordpress, none of the above works for me.

    Creating a php file in mu-plugins folder of Wordpress worked, like :

    <?php
    error_reporting(E_ALL &  ~( E_NOTICE | E_USER_NOTICE | E_STRICT | 
    E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_CORE_WARNING | 
    E_USER_WARNING | E_COMPILE_WARNING | E_PARSE )); 
    

    Just name it anything you want ...

    i got the answer from here :

    https://wycks.wordpress.com/2013/12/05/how-to-remove-error-notices-using-wordpresss-wp_debug/

    0 讨论(0)
  • 2020-12-05 05:25

    Most of the time these are nothing to worry about (though the plugin/theme developer should know about these so that they may fix them in a future release). PHP warnings and notices are nothing to worry about on a production site most of the time. Some of these can even be generated because the developer has to keep compatibility with older versions of WordPress as well as older PHP versions.

    define('WP_DEBUG', false);
    

    with this

    ini_set('log_errors','On');
    ini_set('display_errors','Off');
    ini_set('error_reporting', E_ALL );
    define('WP_DEBUG', false);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
    

    If you simply set WP_DEBUG to false in your wp-config.php file you should be fine. These don’t affect your site in any way.

    However, the problem is that some times the above does not work. That can happen most times on cheap shared hosts that force displaying PHP warnings and notices. In that case, you can replace this line from your wp-config.php file:

    0 讨论(0)
  • 2020-12-05 05:26

    You need to edit your:

    wp-config.php
    

    file and modify the following here:

    error_reporting(0);
    @ini_set('display_errors', 0);
    

    otherwise Wordpress overwrites the ALERTS set by PHP.INI

    0 讨论(0)
  • 2020-12-05 05:27

    if you want to hide only errors that comes from this function you can use

    @function wp_check_invalid_utf8( $string, $strip = false )
    {
    
    }
    
    0 讨论(0)
提交回复
热议问题