Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove warning messages in PHP

People also ask

How do I turn off warnings in PHP?

in Core Php to hide warning message set error_reporting(0) at top of common include file or individual file. This is the best solution, when it comes to hide logs in Wordpress.

How do I turn off PHP warnings in WordPress?

Either way, you're looking for the “WP_DEBUG” portion of the wp-config. php file. Click the “Save Changes” button in the top right. Once the file is saved, this will disable the PHP warnings in WordPress.

What is warning error in PHP?

A warning error in PHP does not stop the script from running. It only warns you that there is a problem, one that is likely to cause bigger issues in the future. The most common causes of warning errors are: Calling on an external file that does not exist in the directory. Wrong parameters in a function.


You really should fix whatever's causing the warning, but you can control visibility of errors with error_reporting(). To skip warning messages, you could use something like:

error_reporting(E_ERROR | E_PARSE);

You can put an @ in front of your function call to suppress all error messages.

@yourFunctionHere();

To suppress warnings while leaving all other error reporting enabled:

error_reporting(E_ALL ^ E_WARNING); 

If you don't want to show warnings as well as errors use

// Turn off all error reporting
error_reporting(0);

Error Reporting - PHP Manual


If you want to suppress the warnings and some other error types (for example, notices) while displaying all other errors, you can do:

error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);

in Core Php to hide warning message set error_reporting(0) at top of common include file or individual file.

In Wordpress hide Warnings and Notices add following code in wp-config.php file

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