set_error_handler

Supported Versions: PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8
Sets a user-defined error handler function
<?php set_error_handler(?callable $callback, int $error_levels = E_ALL): ?callable
<?php     try {

        \trigger_error($error, E_USER_ERROR);

    } catch (\Throwable $e) {

        \set_error_handler(null);

        \trigger_error($error, E_USER_ERROR);

    }

}
<?php     {

        $errors = [];



        set_error_handler(function ($errno, $errstr, $errfile, $errline) use (&$errors) {

            $errors[] = compact('errno', 'errstr', 'errfile', 'errline');

        });



        $this->errors = &$errors;

    }