3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php final class EventManager { public static function call($sEvent) { $aClasses = ['B']; foreach ($aClasses as $sClassName) { $oMethodChecking = new ReflectionMethod($sClassName,$sFunctionName); $sFunctionName = 'event_'.$sEvent; if (method_exists($sClassName, $sFunctionName) && $oMethodChecking->isStatic()) { call_user_func($sClassName.'::'.$sFunctionName); } } } } final class B { public static function event_event_name() { echo 'ok'; } } EventManager::call('event_name');
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: sFunctionName in /in/UpOX8 on line 9 Fatal error: Uncaught ReflectionException: Method B::() does not exist in /in/UpOX8:9 Stack trace: #0 /in/UpOX8(9): ReflectionMethod->__construct('B', '') #1 /in/UpOX8(25): EventManager::call('event_name') #2 {main} thrown in /in/UpOX8 on line 9
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Notice: Undefined variable: sFunctionName in /in/UpOX8 on line 9 Fatal error: Uncaught exception 'ReflectionException' with message 'Method B::() does not exist' in /in/UpOX8:9 Stack trace: #0 /in/UpOX8(9): ReflectionMethod->__construct('B', '') #1 /in/UpOX8(25): EventManager::call('event_name') #2 {main} thrown in /in/UpOX8 on line 9
Process exited with code 255.
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/UpOX8 on line 6
Process exited with code 255.