3v4l.org

run code in 300+ 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 Bar {} class Foo { public function hello() { return "Hello world" . PHP_EOL; } } $mondayKey = WeekDay::Monday; echo "== WEAKMAP WITH ENUM ==" . PHP_EOL; $map = new WeakMap(); $map[$mondayKey] = new Foo(); // etc echo "Dumping the Map with an ENUM" . PHP_EOL; var_dump($map); echo "unsetting reference to ENUM's object" . PHP_EOL; unset($mondayKey); echo "Dumping the Map with an ENUM" . PHP_EOL; var_dump($map); echo "IT'STILL THERE !" . PHP_EOL; echo PHP_EOL . PHP_EOL; echo "== WEAKMAP WITH OBJECT ==" . PHP_EOL; $map = new WeakMap(); $objKey = new Bar(); $map[$objKey] = new Foo(); echo "Dumping the Map with an OBJECT" . PHP_EOL; var_dump($map); echo "unsetting the OBJECT" . PHP_EOL; unset($objKey); echo "Dumping the Map with an OBJECT" . PHP_EOL; var_dump($map); echo "IT'S GONE !" . PHP_EOL; echo PHP_EOL . PHP_EOL; $tuesdayKey = WeekDay::Tuesday; $otherTuesdayKey = WeekDay::Tuesday; echo "== SPLOBJECTSTORAGE WITH ENUM ==" . PHP_EOL; $objStore = new SplObjectStorage(); $objStore[$tuesdayKey] = new Foo(); echo "Dumping the SPLOBJECTSTORAGE with an ENUM" . PHP_EOL; var_dump($objStore); echo "unsetting the ENUM" . PHP_EOL; unset($tuesdayKey); echo "Dumping the SPLOBJECTSTORAGE with an ENUM" . PHP_EOL; var_dump($objStore); echo "IT'STILL THERE !" . PHP_EOL; echo PHP_EOL . PHP_EOL; echo "== SPLOBJECTSTORAGE WITH OBJECT ==" . PHP_EOL; $objStore = new SplObjectStorage(); $objKey = new Bar(); $objStore[$objKey] = new Bar(); echo "Dumping the SPLOBJECTSTORAGE with an OBJECT" . PHP_EOL; var_dump($objStore); echo "unsetting the OBJECT" . PHP_EOL; unset($tuesdayKey); echo "Dumping the SPLOBJECTSTORAGE with an OBJECT" . PHP_EOL; var_dump($objStore); echo "IT'STILL THERE !" . PHP_EOL;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.10.0090.01016.58
8.5.00.0150.00823.02
8.4.150.0020.00114.05
8.4.140.0070.01417.56
8.4.130.0060.00417.83
8.4.120.0440.00917.42
8.4.110.0110.00717.64
8.4.90.0110.01017.70
8.3.280.0020.00014.05
8.3.270.0140.00616.67
8.3.260.0130.00716.43
8.3.250.0120.00916.39
8.3.240.0080.00816.56
8.3.180.0100.00918.26
8.3.50.0120.00716.70

preferences:
35.59 ms | 403 KiB | 5 Q