For a simple case of their registration:
set_error_handler(function($errno, $errstr, $errfile, $errline) use ($db) {
Instead of just writing them to your database (with the likelihood you won't look at them after a while), you can also let these warnings, notifications, etc. throw an exception:
function exception_error_handler($errno, $errstr, $errfile, $errline) { if (error_reporting()) { // skip errors that were muffled throw new ErrorException($errstr, $errno, 0, $errfile, $errline); } } set_error_handler("exception_error_handler");
Source: ErrorException
An exception will have more serious side effects, so you should have
source share