3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Out extends Exception { private $value; function __construct($value) { $this->value = $value; } function getValue() { return $this->value; } } function out() { throw new Out(); } function mul($x, $y) { try { return ($x ?? out(NULL)) * ($y ?? out(NULL)); } catch (Out $out) { return $out->getValue(); } } var_export(mul(3, 4)); print "\n"; var_export(mul(3, NULL)); print "\n"; var_export(mul(NULL, 4)); print "\n";
Output for git.master, git.master_jit, rfc.property-hooks
12 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Out::__construct(), 0 passed in /in/uU1U6 on line 14 and exactly 1 expected in /in/uU1U6:5 Stack trace: #0 /in/uU1U6(14): Out->__construct() #1 /in/uU1U6(19): out(NULL) #2 /in/uU1U6(28): mul(3, NULL) #3 {main} thrown in /in/uU1U6 on line 5
Process exited with code 255.

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:
18.88 ms | 401 KiB | 8 Q