3v4l.org

run code in 300+ PHP versions simultaneously
<?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
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
ondie Fatal error: Uncaught DivisionByZeroError: Division by zero in /in/drQVE:13 Stack trace: #0 {main} thrown in /in/drQVE on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in /in/drQVE on line 5 ondie
Output for 7.3.32 - 7.3.33
ondie
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.21
ondieDoh

preferences:
181.48 ms | 402 KiB | 243 Q