3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Output for 7.0.0 - 7.2.0
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.
Output for 5.3.19 - 5.3.29, 5.4.7 - 5.6.28
Fatal error: Call to undefined function callWhateverYouWhant() in /in/MdJYD on line 6
Process exited with code 255.
Output for 5.4.0 - 5.4.6
Fatal error: Call to undefined function callWhateverYouWhant() in /in/MdJYD on line 6