3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class BaseClass { private static $queryClass = 'StaticSqlQuery'; public static function setQueryClass($className) { static::$queryClass = $className; } public static function test() { return forward_static_call([static::$queryClass, 'init']); } } class StaticSqlQuery { public static function init() { return 'Original call'; } } echo BaseClass::test(); BaseClass::setQueryClass( get_class(new class extends StaticSQLQuery { public static function init() { return 'My stub'; } }) ); echo BaseClass::test();
based on YeFGk
Output for 7.0.0 - 7.2.0
Original callMy stub
Output for 5.4.11 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/7VZD5 on line 25
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/7VZD5 on line 12
Process exited with code 255.