- ob_start: documentation ( source)
- ob_get_contents: documentation ( source)
- register_shutdown_function: documentation ( source)
- ob_end_clean: documentation ( source)
<?php
function onDie(){
$message = ob_get_contents(); //Capture 'Doh'
ob_end_clean(); //Cleans output buffer
echo 'ondie'.$message;
//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
echo 'asdfsdfd';