3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(ticks=1) function tick_handler() { echo "tick_handler() called\n"; } function inverse($x) {tick_handler(); if (1/0) { throw new Exception('Division by zero.'); } return 1/$x; } try { echo inverse(5) . "\n"; echo inverse(0) . "\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } echo inverse(0) . "\n"; ?>
Output for 5.4.0 - 5.4.20, 5.5.0 - 5.5.4
Parse error: syntax error, unexpected 'tick_handler' (T_STRING), expecting '(' in /in/Yrsh2 on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING, expecting '(' in /in/Yrsh2 on line 3
Process exited with code 255.

preferences:
180.99 ms | 1395 KiB | 61 Q