At times you don't see any messages in the log file or you see a blank page instead of output or you only see fatal or critical errors but not information or notice messages etc and you may wonder why. This is because PHP has so many log level. What you see in the logs correspond to error reporting level set at global level in php.ini. This error reporting level can also be overwritten at runtime by in the script. The various error reporting levels are defined as constants and string enums as follows.
* Examples of error reporting override
// Turn off all error reporting
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// Report all PHP errors
// Same as error_reporting(E_ALL);
One of the interesting use-case could change the error level dynamically to report all errors lets say for a
developer (development) and display no errors when its customer facing (production). This switch can be done
based on IP address or some other criteria.
// Only display php errors to the developer
// Just replace 127.0.0.1 with your ip address.