3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Entity { public function getId() : ?int; } class Comment implements Entity { private ?int $id = null; private int $userId; private string $text; public function __construct(int $userId, string $text) { $this->userId = $userId; $this->text = $text; } public function getId() : ?int { return $this->id; } public function setId(int $id) : void { $this->id = $id; } } class PseudoDatabase { private array $entities = []; public function save(Entity $entity) { $id = $entity->getId(); if (null === $id) { $id = $this->generateId(); $entity->setId($id); } $this->entities[$id] = $entity; } private function generateId() : int { return random_int(1, 1000000); } } $comment = new Comment(11, 'Test comment'); $database = new PseudoDatabase; $database->save($comment); var_dump($comment);

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)
7.4.10.0110.00716.52
7.4.00.0120.00616.57
7.3.130.0080.00716.16
7.3.120.0080.00816.29
7.3.110.0120.00916.08
7.3.100.0060.01216.16
7.3.90.0060.00816.18
7.3.80.0060.01516.28
7.3.70.0090.00616.11
7.3.60.0090.00516.21
7.3.50.0060.00916.27
7.3.40.0060.00916.16
7.3.30.0060.00916.16
7.3.20.0090.00616.13
7.3.10.0070.01016.14
7.3.00.0080.00816.27
7.2.260.0080.00616.18
7.2.250.0110.01116.24
7.2.240.0080.01216.48
7.2.230.0150.00616.23
7.2.220.0160.00016.36
7.2.210.0090.00816.40
7.2.200.0040.01116.29
7.2.190.0080.00716.43
7.2.180.0040.01516.33
7.2.170.0100.00716.32
7.2.160.0160.00316.34
7.2.150.0100.00616.40
7.2.140.0060.01316.30
7.2.130.0030.01716.48
7.2.120.0120.00616.37
7.2.110.0090.00916.20
7.2.100.0090.01216.32
7.2.90.0100.01316.30
7.2.80.0070.01316.21
7.2.70.0070.01016.42
7.2.60.0050.01416.46
7.2.50.0130.00616.29
7.2.40.0100.00716.54
7.2.30.0060.01216.41
7.2.20.0140.00616.31
7.2.10.0150.00316.36
7.2.00.0130.01316.46

preferences:
29.81 ms | 401 KiB | 5 Q