3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __construct() { $args = func_get_args(); switch (count($args)) { case 2: return call_user_func_array(array($this, 'constr2'), $args); case 1: return call_user_func_array(array($this, 'constr1'), $args); } 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 constr2 called Fatal error: Uncaught Exception: invalid number of arguments in /in/fSEc3:12 Stack trace: #0 /in/fSEc3(24): Foo->__construct('a', 'b', 3) #1 {main} thrown in /in/fSEc3 on line 12
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:
73.41 ms | 401 KiB | 8 Q