class
ErrorHandler {
private
static
$instance
= null;
private
static
$errors
= [];
public
static
function
Init() {
if
(!self::
$instance
) {
self::
$instance
=
new
self;
set_error_handler(
function
(
$errno
,
$errstr
,
$errfile
,
$errline
){
self::
$errors
[] =
new
ErrorException(
$errstr
, 0,
$errno
,
$errfile
,
$errline
);
});
set_exception_handler(
function
(
$ex
){
self::
$errors
[] =
$ex
;
});
}
}
function
__destruct(){
foreach
(self::
$errors
as
$errstr
)
echo
$errstr
,
'<br>'
;
}
}
ErrorHandler::Init();