3v4l.org

run code in 300+ PHP versions simultaneously
<?php $set = new SplObjectStorage(); enum Foo: int { case Bar = 1; case Baz = 2; } $set[Foo::Bar] = 'bar'; $set[Foo::Baz] = 'baz'; var_dump($set); $set[Foo::Bar] = 'barrrr'; var_dump($set);
Output for 8.1.0 - 8.1.2
object(SplObjectStorage)#1 (1) { ["storage":"SplObjectStorage":private]=> array(2) { [0]=> array(2) { ["obj"]=> enum(Foo::Bar) ["inf"]=> string(3) "bar" } [1]=> array(2) { ["obj"]=> enum(Foo::Baz) ["inf"]=> string(3) "baz" } } } object(SplObjectStorage)#1 (1) { ["storage":"SplObjectStorage":private]=> array(2) { [0]=> array(2) { ["obj"]=> enum(Foo::Bar) ["inf"]=> string(6) "barrrr" } [1]=> array(2) { ["obj"]=> enum(Foo::Baz) ["inf"]=> string(3) "baz" } } }
Output for 8.0.1 - 8.0.15
Parse error: syntax error, unexpected identifier "Foo" in /in/hqavf on line 4
Process exited with code 255.
Output for 7.4.0 - 7.4.27
Parse error: syntax error, unexpected 'Foo' (T_STRING) in /in/hqavf on line 4
Process exited with code 255.

preferences:
192.86 ms | 1395 KiB | 51 Q