3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Status: int { case Open = 1; case Close = 2; case Invalid = 3; const Values = [ self::Open->value => self::Open, self::Close->value => self::Close, self::Invalid->value => self::Invalid, ]; } class Foo { const BAR = Status::Values; } var_dump(Foo::BAR);
Output for 8.2.0 - 8.2.25, 8.3.5 - 8.3.14
array(3) { [1]=> enum(Status::Open) [2]=> enum(Status::Close) [3]=> enum(Status::Invalid) }
Output for 8.1.0 - 8.1.30
Fatal error: Constant expression contains invalid operations in /in/cDmN8 on line 9
Process exited with code 255.
Output for 8.0.1 - 8.0.28
Parse error: syntax error, unexpected identifier "Status" in /in/cDmN8 on line 3
Process exited with code 255.

preferences:
37.75 ms | 408 KiB | 5 Q