<?php
function onDie(){
$message = ob_get_contents(); //Capture 'Doh'
ob_end_clean(); //Cleans output buffer
callWhateverYouWhant();
}
register_shutdown_function('onDie');
//...
ob_start(); //You need this to Turn on output buffering before using die/exit
@$dumbVar = 1000/0 or die('Doh'); //"@" prevent warning/error from php
//...
ob_end_clean(); //Remember clean your buffer before you need to use echo/print
Fatal error: Uncaught Error: Call to undefined function callWhateverYouWhant() in /in/MdJYD:6
Stack trace:
#0 [internal function]: onDie()
#1 {main}
thrown in /in/MdJYD on line 6
Process exited with code 255.
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in /in/MdJYD on line 5
Fatal error: Uncaught Error: Call to undefined function callWhateverYouWhant() in /in/MdJYD:6
Stack trace:
#0 [internal function]: onDie()
#1 {main}
thrown in /in/MdJYD on line 6
Process exited with code 255.