- explode: documentation ( source)
- set_exception_handler: documentation ( source)
- set_error_handler: documentation ( source)
<?php
declare(strict_types=1);
set_error_handler(function ($n, $message) {
echo 'Error handler called: ' . $message . PHP_EOL;
});
set_exception_handler(function ($e) {
echo 'Exception handler called: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL;
});
function strict(int $i) {}
explode(['not', 'valid'], ['arguments']);
try {
explode(['not', 'valid'], ['arguments']);
} catch (Throwable $e) {
echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL;
}
try {
eval('eval is evil');
} catch (ParseError $e) {
echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL;
}
try {
echo 1 / 0;
} catch (DivisionByZeroError $e) {
echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL;
}
try {
strict('one');
} catch (TypeError $e) {
echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL;
}