<?php
set_error_handler('myErrorHandler');
register_shutdown_function('fatalErrorShutdownHandler');
echo 'Fatal Error Handler ..';
function myErrorHandler($code, $message, $file, $line) {
}
function fatalErrorShutdownHandler()
{
$last_error = error_get_last();
if ($last_error['type'] === E_ERROR) {
// fatal error
myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
}
}
final class Email {
const EMAIL = "me@where.com";
private function __destruct() {
echo 'Destroying ...',"\n";
return;
}
}
$vo = new Email;
echo $vo::EMAIL,"\n";
try {
$vo = null;
echo 'nullified',"\n";
} catch(Exception $e) {
echo $e->getMessage();
} finally {
echo "You should not destroy the value object","\n";
}
var_dump($vo);
preferences:
30.56 ms | 402 KiB | 5 Q