3v4l.org

run code in 500+ PHP versions simultaneously
<?php enum WeekDay: string { case Monday = 'monday'; case Tuesday = 'tuesday'; case Wednesday = 'wednesday'; case Thursday = 'thursday'; case Friday = 'friday'; case Saturday = 'saturday'; case Sunday = 'sunday'; } class Foo { public function hello() { return "Hello world" . PHP_EOL; } } $array = []; $array[WeekDay::Monday->value] = new Foo(); // etc echo $array[WeekDay::Monday->value]->hello(); $map = new WeakMap(); $map[WeekDay::Monday] = new Foo(); // etc echo $map[WeekDay::Monday]->hello();
Output for 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
Hello world Hello world

preferences:
49.07 ms | 864 KiB | 4 Q