3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __construct() { $args = func_get_args(); switch (count($args)) { case 2: call_user_func_array(array($this, 'constr2'), $args); break; case 1: call_user_func_array(array($this, 'constr1'), $args); break; } throw new Exception("invalid number of arguments"); } protected function constr1($a) { print "constr1 called\n"; } protected function constr2($a, $b) { print "constr2 called\n"; } } $a = new Foo(2); $b = new Foo(2, 3); $c = new Foo("a", "b", 3);
Output for git.master, git.master_jit, rfc.property-hooks
constr1 called Fatal error: Uncaught Exception: invalid number of arguments in /in/TKWKE:14 Stack trace: #0 /in/TKWKE(24): Foo->__construct(2) #1 {main} thrown in /in/TKWKE on line 14
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:
42.88 ms | 401 KiB | 8 Q