3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 />" ); ?>
based on 3mWaW
Output for 5.4.11 - 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.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/b0vbb on line 4
Process exited with code 255.