3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { public static $baz = 5; protected static $bat = 4; private static $qux = 3; } $r = new ReflectionClass(Bar::class); var_dump($r->getStaticPropertyValue('baz')); var_dump($r->getStaticPropertyValue('bat')); var_dump($r->getStaticPropertyValue('qux'));
Output for 7.4.9 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(5) int(4) int(3)
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.8
int(5) Fatal error: Uncaught ReflectionException: Class Bar does not have a property named bat in /in/ftquS:12 Stack trace: #0 /in/ftquS(12): ReflectionClass->getStaticPropertyValue('bat') #1 {main} thrown in /in/ftquS on line 12
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
int(5) Fatal error: Uncaught exception 'ReflectionException' with message 'Class Bar does not have a property named bat' in /in/ftquS:12 Stack trace: #0 /in/ftquS(12): ReflectionClass->getStaticPropertyValue('bat') #1 {main} thrown in /in/ftquS on line 12
Process exited with code 255.
Output for 5.4.2 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/ftquS on line 10
Process exited with code 255.

preferences:
188.14 ms | 401 KiB | 256 Q