3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private array $elements = []; public function __construct(int $howMany) { for ($i = 0; $i < $howMany; $i++) { $this->elements[] = random_int(1, 100); } } public function &getElements():array { return $this->elements; } } class Demo { public Foo $foo; public function __construct(int $howMany) { $this->foo = new Foo($howMany); } public function demo(): void { echo "\nWe start with ", count($this->foo->getElements()), " soldiers in \$foo->elements\n"; $this->removeElement(); echo "\nWe now have ", count($this->foo->getElements()), " soldiers in \$foo->elements\n"; } private function removeElement(): void { $elements = &$this->foo->getElements(); array_splice($elements, 2, 1); } } $init = random_int(4,10); $demo = new Demo($init); $demo->demo(); $remaining = count($demo->foo->getElements()); if ($init-1 !== $remaining) { throw new UnexpectedValueException('Wrong number of elements, application is broken'); }

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.0.110.0000.00816.75
8.0.100.0060.00316.98
8.0.90.0000.00816.98
8.0.80.0040.00416.94
8.0.70.0030.00516.82
8.0.60.0030.00616.91
8.0.50.0030.00516.94
8.0.30.0000.00716.89
8.0.20.0040.00416.97
8.0.10.0060.00316.98
8.0.00.0000.00717.04
7.4.240.0050.00316.52
7.4.230.0050.00316.60
7.4.220.0050.00316.58
7.4.210.0000.00716.44
7.4.200.0090.00016.63
7.4.190.0000.00816.59
7.4.180.0000.00816.67
7.4.160.0030.00716.62
7.4.150.0040.00416.56
7.4.140.0050.00316.53
7.4.130.0060.00316.47
7.4.120.0000.00716.52
7.4.110.0040.00416.57
7.4.100.0000.00816.38
7.4.90.0000.00716.30
7.4.80.0000.00716.50
7.4.70.0040.00416.54
7.4.60.0040.00416.55
7.4.50.0030.00516.42
7.4.40.0030.00516.43
7.4.30.0000.00816.37
7.4.20.0040.00416.46
7.4.10.0030.00516.44
7.4.00.0000.00716.54
7.3.310.0000.00815.99
7.3.300.0090.00016.10
7.3.290.0070.00016.13
7.3.280.0100.00016.16
7.3.270.0000.00716.18
7.3.260.0080.00016.25
7.3.250.0050.00216.17
7.3.240.0050.00216.22
7.3.230.0000.00816.16
7.3.220.0000.00716.07
7.3.210.0040.00415.96
7.3.200.0070.00016.25
7.3.190.0070.00016.15
7.3.180.0050.00315.89
7.3.170.0030.00316.25
7.3.160.0000.00716.07
7.3.150.0040.00416.11
7.3.140.0040.00416.17
7.3.130.0080.00016.18
7.3.120.0000.00815.91
7.3.110.0070.00016.19
7.3.100.0000.00816.05
7.3.90.0070.00016.34
7.3.80.0070.00016.18
7.3.70.0000.00716.13
7.3.60.0000.00816.21
7.3.50.0040.00416.18
7.3.40.0030.00316.06
7.3.30.0060.00316.26
7.3.20.0030.00616.36
7.3.10.0050.00316.15
7.3.00.0000.00816.21

preferences:
40.19 ms | 403 KiB | 5 Q