3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Foo { case TEST; } $ref = new \ReflectionClass(Foo::class); var_dump($ref->getConstant('TEST')); var_dump($ref->getReflectionConstant('TEST')->getValue()); var_dump(constant('Foo::TEST'));
Output for 8.1.0, 8.2.22 - 8.2.23, 8.3.5 - 8.3.11
enum(Foo::TEST) enum(Foo::TEST) enum(Foo::TEST)
Output for 8.0.0 - 8.0.13
Parse error: syntax error, unexpected identifier "Foo" in /in/4gqGD on line 3
Process exited with code 255.
Output for 7.3.13 - 7.3.33, 7.4.0 - 7.4.27
Parse error: syntax error, unexpected 'Foo' (T_STRING) in /in/4gqGD on line 3
Process exited with code 255.

preferences:
56.69 ms | 408 KiB | 5 Q