3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A0 { function foo($a, $b) { $a + $b; } } class A1 { function foo($a, $b) { $a + $b; } } class A2 { function foo($a, $b) { $a + $b; } } class A3 { function foo($a, $b) { $a + $b; } } class A4 { function foo($a, $b) { $a + $b; } } class A5 { function foo($a, $b) { $a + $b; } } class A6 { function foo($a, $b) { $a + $b; } } function row($name, $t) { printf("%-40s %8s x 10 ┬Ás\n", $name, number_format((microtime(true)-$t)*1e5, 2)); } $max = 5*1e1; $count = 7; $objects = array(new A0, new A1, new A2, new A3, new A4, new A5, new A7) ; $t = microtime (true); for ($j=0; $j<$count; $j++) { for ($i=0; $i<$max; $i++) { $objects[$j]->foo(1, 'foo'); } } row($max.' x A::foo', $t); $t = microtime (true); for ($j=0; $j<$count; $j++) { for ($i=0; $i<$max; $i++) { call_user_func_array(array($objects[$j], 'foo'), array(1, 'foo')); } } row($max.' x call_user_func_array', $t); $t = microtime (true); for ($j=0; $j<$count; $j++) { $ref = new ReflectionMethod($objects[$j], 'foo'); for ($i=0; $i<$max; $i++) { $ref->invokeArgs($objects[$j], array(1, 'foo')); } } row($max.' x ReflectionMethod::invokeArgs', $t);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Class 'A7' not found in /in/UoBTO:50 Stack trace: #0 {main} thrown in /in/UoBTO on line 50
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Class 'A7' not found in /in/UoBTO on line 50
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: a7 in /in/UoBTO on line 50
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: a7 in /in/UoBTO on line 50