3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Exception1 extends Exception { } class Exception2 extends Exception { } function foo($case) { $e = null; try { if ($case == 1) { echo "throw exception 1\n"; throw new Exception1(); } else if ($case == 2) { echo "throw exception 2\n"; throw new Exception2(); } else { echo "successful\n"; return "success"; } } catch (Exception1 $e) { echo "caught exception 1\n"; return "failure 1"; } catch (Exception2 $e) { echo "caught exception 2\n"; return "failure 2"; } finally { if ($e) { echo "finally with error\n"; } else { echo "finally with success\n"; } } } echo "Success:\n"; echo "Returns: " . foo(0) . "\n"; echo "\nCase 1 throws Exception1:\n"; echo "Returns: " . foo(1) . "\n"; echo "\nCase 2 throws Exception2:\n"; echo "Returns: " . foo(2) . "\n";
Output for git.master, git.master_jit, rfc.property-hooks
Success: successful finally with success Returns: success Case 1 throws Exception1: throw exception 1 caught exception 1 finally with error Returns: failure 1 Case 2 throws Exception2: throw exception 2 caught exception 2 finally with error Returns: failure 2

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
165.5 ms | 406 KiB | 5 Q