3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php declare(ticks=1); function tick_handler() { echo "tick_handler() called\n"; } function inverse($x) {tick_handler(); if (!$x) {tick_handler(); throw new Exception('Division by zero.');tick_handler(); } return 1/$x;tick_handler(); } try { echo inverse(5) . "\n"; echo inverse(0) . "\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } echo inverse(0) . "\n"; ?>
Output for 7.0.0 - 7.1.0
tick_handler() called 0.2 tick_handler() called tick_handler() called Caught exception: Division by zero. tick_handler() called tick_handler() called Fatal error: Uncaught Exception: Division by zero. in /in/AF251:11 Stack trace: #0 /in/AF251(25): inverse(0) #1 {main} thrown in /in/AF251 on line 11
Process exited with code 255.
Output for 5.2.3 - 5.6.28
tick_handler() called 0.2 tick_handler() called tick_handler() called Caught exception: Division by zero. tick_handler() called tick_handler() called Fatal error: Uncaught exception 'Exception' with message 'Division by zero.' in /in/AF251:11 Stack trace: #0 /in/AF251(25): inverse(0) #1 {main} thrown in /in/AF251 on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.2, 5.0.5 - 5.2.2
tick_handler() called 0.2 tick_handler() called tick_handler() called Caught exception: Division by zero. tick_handler() called tick_handler() called <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'Division by zero.' in /in/AF251:11 Stack trace: #0 /in/AF251(25): inverse(0) #1 {main} thrown in <b>/in/AF251</b> on line <b>11</b><br />
Process exited with code 255.
Output for 5.0.3 - 5.0.4
tick_handler() called 0.2 tick_handler() called tick_handler() called Caught exception: Division by zero. tick_handler() called tick_handler() called <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'Division by zero.' in /in/AF251:11 Stack trace: #0 /in/AF251(11): inverse() #1 /in/AF251(25): inverse(0) #2 {main} thrown in <b>/in/AF251</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_NEW in <b>/in/AF251</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_NEW in <b>/in/AF251</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/AF251</b> on line <b>11</b><br />
Process exited with code 255.