3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Foo { case BAR; } class MyClass { public $enumProperty = Foo::BAR; public $regularProperty = 'default'; } var_dump(new MyClass); var_dump((new ReflectionClass(MyClass::class))->getDefaultProperties());
Output for 8.1.0 - 8.1.30, 8.2.21 - 8.2.24, 8.3.5 - 8.3.12
object(MyClass)#2 (2) { ["enumProperty"]=> enum(Foo::BAR) ["regularProperty"]=> string(7) "default" } array(2) { ["enumProperty"]=> enum(Foo::BAR) ["regularProperty"]=> string(7) "default" }
Output for 8.0.1 - 8.0.17
Parse error: syntax error, unexpected identifier "Foo" in /in/jBhDg on line 3
Process exited with code 255.
Output for 7.4.0 - 7.4.28
Parse error: syntax error, unexpected 'Foo' (T_STRING) in /in/jBhDg on line 3
Process exited with code 255.

preferences:
50.99 ms | 408 KiB | 5 Q