<?php
set_error_handler(function($no, $str, $file, $line) {
throw new ErrorException($str, 0, $no, $file, $line);
});
set_exception_handler(function(\Exception $e) {
echo "Halp! I cant rite teh codez: " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
});
function crappy_codez()
{
trigger_error("You dun made a mistaek", E_USER_WARNING);
}
echo "La-di-dah, off I go to do something\n";
crappy_codez();
echo "F*ck it, that'll do, I'm off down the pub";