3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum MyEnum: string { case Foo = 'foo'; } #[Attribute] class MyAttribute { public function __construct( public readonly string $myProperty, ) {} } echo MyEnum::Foo->value; #[MyAttribute(MyEnum::Foo->value)] class MyClass {}
Output for 8.1.0 - 8.1.6
Fatal error: Constant expression contains invalid operations in /in/E6Y9V on line 19
Process exited with code 255.
Output for 8.0.1 - 8.0.19
Parse error: syntax error, unexpected identifier "MyEnum" in /in/E6Y9V on line 3
Process exited with code 255.
Output for 7.4.0 - 7.4.29
Parse error: syntax error, unexpected 'MyEnum' (T_STRING) in /in/E6Y9V on line 3
Process exited with code 255.

preferences:
193.2 ms | 1395 KiB | 61 Q