3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $sFunctionName in /in/UpOX8 on line 9 Fatal error: Uncaught ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in /in/UpOX8:9 Stack trace: #0 /in/UpOX8(9): ReflectionMethod->__construct('B', NULL) #1 /in/UpOX8(25): EventManager::call('event_name') #2 {main} thrown in /in/UpOX8 on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
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 7.3.32 - 7.3.33
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.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
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.

preferences:
258.26 ms | 402 KiB | 376 Q