3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public static method foo() { return 1; } } function fa () { return 1; } function fb () { return 1; } function fc () { return 1; } $calla = 'fa'; $callb = 'fb'; $callc = 'fc'; $class = 'Test'; $method = 'foo();' $calld = $class.'::'.$method.'()'; $time = microtime( true ); for( $i = 5000; $i--; ) { $x = 0; $x += $calla(); $x += $callb(); $x += $callc(); $x += $calld(); if( $x != 4 ) die( 'Bad numbers' ); } echo( "Variable functions took " . (microtime( true ) - $time) . " seconds.<br />" ); $time = microtime( true ); for( $i = 5000; $i--; ) { $x = 0; $x += call_user_func($calla); $x += call_user_func($callb); $x += call_user_func($callc); $x += call_user_func($calld); if( $x != 4 ) die( 'Bad numbers' ); } echo( "call_user_func took " . (microtime( true ) - $time) . " seconds.<br />" ); $time = microtime( true ); for( $i = 5000; $i--; ) { $x = 0; $x += call_user_func([$class, $method]); if( $x != 1 ) die( 'Bad numbers' ); } echo( "call_user_func 2 took " . (microtime( true ) - $time) . " seconds.<br />" ); ?>
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16, 7.0.0 - 7.0.2
Parse error: syntax error, unexpected 'method' (T_STRING), expecting variable (T_VARIABLE) in /in/b0vbb on line 4
Process exited with code 255.

preferences:
152.78 ms | 1443 KiB | 7 Q