- var_dump: documentation ( source)
- set_exception_handler: documentation ( source)
- restore_error_handler: documentation ( source)
- set_error_handler: documentation ( source)
<?php
function accept_callable(callable $arg) {}
class Foo {
public function __construct() {
set_error_handler([$this, 'log_error']);
set_exception_handler([$this, 'log_exception']);
}
private function log_error( $type, $message, $file, $line ) {
echo "log error" . PHP_EOL;
return true;
}
public function log_exception( $e ) {
echo "log exception" . PHP_EOL;
var_dump($e);
}
}
$foo = new Foo();
$previousHandler = set_error_handler(static fn () => false);
restore_error_handler();
accept_callable($previousHandler);