3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); namespace App { class Status { const ACTIVE = 1; const INACTIVE = 2; const SOLD = 3; private $value; private $labels = [ self::ACTIVE => 'Active', self::INACTIVE => 'Inactive', self::SOLD => 'Sold', ]; /** * Status constructor. * @param $value */ public function __construct(int $value) { if (!in_array($value, array_keys($this->labels))) { throw new \InvalidArgumentException('Invalid status'); } $this->value = $value; } public function __toString() { return $this->labels[$this->value]; } } class Product { private $id; private $name; private $status; /** * Product constructor. * @param $id * @param $name * @param $status */ public function __construct(int $id, string $name, Status $status) { $this->id = $id; $this->name = $name; $this->status = $status; } } $status = new Status(Status::SOLD); var_dump(new Product(1, 'Chess board', $status)); echo "\n\n\n\n{$status}"; }

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.3.60.0070.01418.68
8.3.50.0130.00318.05
8.3.40.0070.01418.84
8.3.30.0080.01118.85
8.3.20.0080.00020.26
8.3.10.0000.00820.53
8.3.00.0050.00321.73
8.2.180.0110.00718.20
8.2.170.0170.00322.96
8.2.160.0070.00722.08
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0040.00421.05
8.2.120.0080.00026.35
8.2.110.0100.00020.43
8.2.100.0090.00317.97
8.2.90.0000.00819.17
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0000.00817.93
8.2.50.0040.00418.09
8.2.40.0080.00020.52
8.2.30.0040.00419.54
8.2.20.0030.00617.65
8.2.10.0070.00018.18
8.2.00.0000.00818.09
8.1.280.0000.01825.92
8.1.270.0060.01222.25
8.1.260.0020.00528.09
8.1.250.0050.00228.09
8.1.240.0030.00723.91
8.1.230.0030.00720.87
8.1.220.0080.00017.74
8.1.210.0050.00318.77
8.1.200.0030.00917.25
8.1.190.0050.00317.38
8.1.180.0050.00318.10
8.1.170.0040.00418.50
8.1.160.0040.00420.71
8.1.150.0030.00618.98
8.1.140.0040.00419.65
8.1.130.0030.00317.73
8.1.120.0040.00417.39
8.1.110.0040.00417.39
8.1.100.0000.00717.39
8.1.90.0040.00417.52
8.1.80.0040.00417.52
8.1.70.0030.00617.38
8.1.60.0060.00317.47
8.1.50.0000.00917.46
8.1.40.0030.00517.52
8.1.30.0040.00417.58
8.1.20.0000.00717.63
8.1.10.0080.00017.52
8.1.00.0040.00417.61
8.0.300.0080.00018.77
8.0.290.0090.00016.75
8.0.280.0070.00018.48
8.0.270.0030.00317.29
8.0.260.0000.00617.32
8.0.250.0030.00616.95
8.0.240.0000.00717.07
8.0.230.0030.00317.07
8.0.220.0050.00317.02
8.0.210.0000.00717.04
8.0.200.0030.00316.97
8.0.190.0040.00417.03
8.0.180.0040.00716.90
8.0.170.0060.00317.05
8.0.160.0000.00716.92
8.0.150.0000.00816.88
8.0.140.0000.00716.89
8.0.130.0060.00013.46
8.0.120.0040.00416.97
8.0.110.0040.00416.94
8.0.100.0040.00416.83
8.0.90.0000.00816.94
8.0.80.0100.00716.92
8.0.70.0040.00416.95
8.0.60.0040.00416.97
8.0.50.0080.00017.05
8.0.30.0090.00817.14
8.0.20.0090.01317.40
8.0.10.0070.00017.17
8.0.00.0120.01016.78
7.4.330.0020.00216.74
7.4.320.0060.00016.45
7.4.300.0030.00316.65
7.4.290.0030.00316.69
7.4.280.0000.00816.52
7.4.270.0040.00416.41
7.4.260.0000.00816.54
7.4.250.0040.00416.54
7.4.240.0040.00416.67
7.4.230.0070.00016.63
7.4.220.0080.01116.66
7.4.210.0110.00416.68
7.4.200.0030.00316.64
7.4.160.0120.00416.75
7.4.150.0110.00717.40
7.4.140.0110.00717.86
7.4.130.0070.01416.58
7.4.120.0100.00816.62
7.4.110.0130.01016.60
7.4.100.0090.01316.46
7.4.90.0090.00916.48
7.4.80.0150.00319.39
7.4.70.0130.00616.40
7.4.60.0070.01416.50
7.4.50.0050.00716.54
7.4.40.0080.00816.65
7.4.30.0160.00316.50
7.4.00.0080.00614.98
7.3.330.0000.00513.20
7.3.320.0030.00313.41
7.3.310.0000.00716.36
7.3.300.0030.00316.14
7.3.290.0080.00916.31
7.3.280.0090.00916.30
7.3.270.0150.00417.40
7.3.260.0060.01116.43
7.3.250.0140.00716.44
7.3.240.0150.00516.45
7.3.230.0140.01016.67
7.3.210.0140.00316.32
7.3.200.0110.00916.45
7.3.190.0070.01316.64
7.3.180.0130.00316.46
7.3.170.0080.00816.64
7.3.160.0080.00816.47
7.3.120.0030.01417.15
7.3.110.0000.01317.15
7.3.100.0030.01317.15
7.3.90.0130.00317.15
7.3.80.0040.01117.15
7.3.70.0080.00817.15
7.3.60.0100.00717.15
7.3.50.0100.00017.15
7.3.40.0080.00817.15
7.3.30.0000.01417.15
7.3.20.0130.00317.15
7.3.10.0110.00617.15
7.3.00.0100.00317.15
7.2.330.0040.01616.66
7.2.320.0160.00616.86
7.2.310.0120.00616.80
7.2.300.0100.00716.70
7.2.290.0100.01016.76
7.2.240.0060.00917.15
7.2.230.0090.00617.15
7.2.220.0140.00317.15
7.2.210.0090.00617.15
7.2.200.0030.01017.15
7.2.190.0000.01617.15
7.2.180.0090.00917.15
7.2.170.0100.00717.15
7.2.160.0100.00717.15
7.2.150.0000.01217.15
7.2.140.0060.00617.15
7.2.130.0040.00817.15
7.2.120.0000.01317.15
7.2.110.0040.01417.15
7.2.100.0000.01017.15
7.2.90.0000.01617.21
7.2.80.0080.00817.15
7.2.70.0000.01817.15
7.2.60.0050.00817.01
7.2.50.0100.00317.15
7.2.40.0030.00617.15
7.2.30.0070.01117.15
7.2.20.0100.00317.15
7.2.10.0100.00617.15
7.2.00.0050.00718.33
7.1.330.0000.01517.15
7.1.320.0070.00717.15
7.1.310.0000.00917.15
7.1.300.0090.00617.15
7.1.290.0100.00717.15
7.1.280.0090.00617.15
7.1.270.0080.00617.15
7.1.260.0100.00717.15
7.1.250.0000.01417.15
7.1.200.0090.00315.94
7.1.100.0070.01017.82
7.1.70.0000.00817.22
7.1.60.0100.01319.19
7.1.50.0060.00616.67
7.1.00.0070.07322.48
7.0.200.0400.00314.68
7.0.60.0230.06721.72
7.0.50.0100.07017.78
7.0.40.0200.07320.11
7.0.30.0470.07720.15
7.0.20.0300.07020.25
7.0.10.0100.08320.16
7.0.00.0100.07020.14
5.6.280.0000.03721.05
5.6.210.0230.04020.62
5.6.200.0030.05718.20
5.6.190.0170.06020.50
5.6.180.0300.05320.52
5.6.170.0300.07020.50
5.6.160.0130.04320.46
5.6.150.0100.03318.19
5.6.140.0130.06018.13
5.6.130.0130.03018.18
5.6.120.0070.08321.13
5.6.110.0070.08021.00
5.6.100.0000.04321.05
5.6.90.0100.07721.08
5.6.80.0230.04720.38
5.5.350.0330.04720.37
5.5.340.0070.08017.99
5.5.330.0070.06720.46
5.5.320.0330.07720.27
5.5.310.0330.07320.20
5.5.300.0030.03718.03
5.5.290.0100.06018.04
5.5.280.0030.06320.86
5.5.270.0100.08320.97
5.5.260.0130.05320.80
5.5.250.0170.07720.48
5.5.240.0000.05320.05

preferences:
36.48 ms | 400 KiB | 5 Q