3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public int $number = 5; } class DIContainerException extends Exception{} interface ContainerInterface { public function get(string $id): mixed; public function has(string $id): bool; } class DIContainer implements ContainerInterface { private array $registered = []; private array $created = []; public function register(string $id, callable $factory): void { if ($this->has($id)) { throw new DIContainerException('Сервис с таким именем уже зарегистрирован.'); } $this->registered[$id] = $factory; } public function get(string $id): mixed { if (array_key_exists($id, $this->created)) { return $this->created[$id]; } elseif ($this->has($id)) { $object = call_user_func($this->registered[$id], $this); $this->created[$id] = $object; return $object; } else { throw new DIContainerException('Сервис с таким именем не зарегистрирован.'); } } public function has(string $id): bool { return isset($this->registered[$id]); } } $container = new DIContainer(); $container->register('Test', function(DIContainer $container) { return new Test(); }); var_dump($container->get('Test'));

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.4.120.0090.01124.10
8.4.110.0090.01119.04
8.4.100.0120.00818.93
8.4.90.0100.01120.60
8.4.80.0120.00817.96
8.4.70.0120.00518.02
8.4.60.0100.00918.81
8.4.50.0120.01018.73
8.4.40.0060.00617.77
8.4.30.0070.01318.87
8.4.20.0150.00018.78
8.4.10.0090.00319.51
8.3.250.0120.00719.09
8.3.240.0120.00817.16
8.3.230.0130.00616.65
8.3.220.0070.00219.07
8.3.210.0060.00316.70
8.3.200.0030.00616.62
8.3.190.0050.00318.87
8.3.180.0080.00616.86
8.3.170.0110.00720.42
8.3.160.0150.00316.52
8.3.150.0150.00317.05
8.3.140.0070.00016.41
8.3.130.0050.00518.36
8.3.120.0070.00319.01
8.3.110.0000.00816.75
8.3.100.0000.01624.06
8.3.90.0040.00426.77
8.3.80.0070.00718.68
8.3.70.0160.00616.63
8.3.60.0110.00416.59
8.3.50.0040.01118.38
8.3.40.0140.00720.39
8.3.30.0070.00720.28
8.3.20.0080.00824.18
8.3.10.0090.00924.66
8.3.00.0120.00624.66
8.2.290.0100.00920.55
8.2.280.0150.00322.40
8.2.270.0090.00919.25
8.2.260.0110.00720.01
8.2.250.0090.00916.53
8.2.240.0080.00018.81
8.2.230.0120.00420.94
8.2.220.0040.00437.54
8.2.210.0040.00426.77
8.2.200.0140.00417.00
8.2.190.0070.01116.63
8.2.180.0060.00916.63
8.2.170.0100.00322.96
8.2.160.0140.00022.96
8.2.150.0050.00325.66
8.2.140.0150.00424.66
8.2.130.0150.00624.66
8.2.120.0090.00924.66
8.2.110.0120.00624.66
8.2.100.0060.01324.66
8.2.90.0150.00324.66
8.2.80.0160.00324.66
8.2.70.0120.00624.66
8.2.60.0130.00624.66
8.2.50.0130.00724.66
8.2.40.0130.00324.66
8.2.30.0100.00624.66
8.2.20.0060.00624.66
8.2.10.0050.00324.66
8.2.00.0060.00324.66
8.1.330.0100.01121.79
8.1.320.0130.00616.15
8.1.310.0150.00016.99
8.1.300.0050.00316.31
8.1.290.0030.01030.84
8.1.280.0090.00925.92
8.1.270.0080.00024.66
8.1.260.0000.00824.66
8.1.250.0040.00424.66
8.1.240.0040.00424.66
8.1.230.0040.00424.66
8.1.220.0040.00424.66
8.1.210.0060.00324.66
8.1.200.0090.00024.66
8.1.190.0140.00324.66
8.1.180.0040.00424.66
8.1.170.0100.00624.66
8.1.160.0040.00824.66
8.1.150.0120.00324.66
8.1.140.0080.00824.66
8.1.130.0070.01324.66
8.1.120.0130.00724.66
8.1.110.0100.00624.66
8.1.100.0090.00624.66
8.1.90.0100.01024.66
8.1.80.0100.01024.66
8.1.70.0120.00924.66
8.1.60.0090.01224.66
8.1.50.0080.00824.66
8.1.40.0120.00924.66
8.1.30.0040.01124.66
8.1.20.0060.01024.66
8.1.10.0070.00724.66
8.1.00.0100.01024.66

preferences:
32.48 ms | 403 KiB | 5 Q