The problem is that everybody, including visitors to your website, will always be able to see the debug messages. And it makes the website looks awful. In addition, WP_DEBUG overrides the behavior of PHP regardless of whether it’s default settings or user settings, which can be only displaying fatal errors and/or showing a white screen of death when errors happened.
WordPress provides a workaround that forces all debug information to be logged and saved to a log file, and prevents the debug information from printed on screen. The trick is also useful if you need to view debug info generated off-screen such as during an AJAX event or WP-cron execution.
The trick to hide the WordPress debug messages from appearing on screen and save the log messages to a log file depends on WP_DEBUG_LOG and WP_DEBUG_DISPLAY constants, both of which can be defined independent of each other, but only effective when WP_DEBUG is set to true.
Use the following code in wp-config.php file, which log all errors, notices and warnings to a file called debug.log in the /wp-content/ directory and suppress all debug messages from displaying on the web pages’ HTML.
define('WP_DEBUG', true); // Enable WP_DEBUG mode define('WP_DEBUG_LOG', true); // Enable logging to the /wp-content/debug.log file define('WP_DEBUG_DISPLAY', false); // Disable display of errors, notices and warnings on screen
@ini_set('display_errors',0);