3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function dynamicMethod($a) { return $a + 1; } public static function staticMethod($a) { return $a + 1; } public function __invoke($a) { return $a + 1; } } $object = new Test(); ///////////////////////// $function = function ($a) { return $a + 1; }; function testFunction($a) { return $a + 1; } // env //echo phpversion(), " ", PHP_OS, PHP_EOL; // dynamic $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $object->dynamicMethod($i); } echo "dyn: ", microtime(true) - $startTime, PHP_EOL; // dynamic call_user_func $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = call_user_func_array(array($object, 'dynamicMethod'), array($i)); } echo "call_user_func: ", microtime(true) - $startTime, PHP_EOL; // static $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = Test::staticMethod($i); } echo "static: ", microtime(true) - $startTime, PHP_EOL; // invoke $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $object($i); } echo "invoke: ", microtime(true) - $startTime, PHP_EOL; // function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = testFunction($i); } echo "func: ", microtime(true) - $startTime, PHP_EOL; // anonymous function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $function($i); } echo "anon: ", microtime(true) - $startTime, PHP_EOL;<?php
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.27
Parse error: syntax error, unexpected '<' in /in/ZLLSu on line 65
Process exited with code 255.

preferences:
184.6 ms | 1395 KiB | 64 Q