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 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.90.0140.00516.84
8.5.80.0130.00616.83
8.5.70.0050.00216.97
8.5.60.0120.00616.75
8.5.50.0070.01116.77
8.5.30.0120.00718.11
8.5.20.0110.00820.23
8.5.10.0090.01016.58
8.5.00.0150.00823.02
8.4.240.0110.01119.68
8.4.230.0170.00519.71
8.4.220.0060.00419.72
8.4.210.0120.00921.39
8.4.180.0130.01122.17
8.4.170.0110.01123.79
8.4.160.0110.01123.94
8.4.150.0080.00516.82
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.330.0060.00318.46
8.3.320.0090.01018.38
8.3.310.0060.00318.53
8.3.300.0120.00918.39
8.3.290.0110.01018.54
8.3.280.0070.00517.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
8.2.320.0130.00717.94
8.2.310.0110.01017.82
8.2.300.0140.00918.00
8.1.340.0100.01019.70

preferences:
53.43 ms | 718 KiB | 5 Q