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::ACTIVE => 'Inactive', self::ACTIVE => 'Sold', ]; /** * Status constructor. * @param $value */ public function __construct(int $value) { if (in_array($value, $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.40.0210.00018.76
8.3.30.0130.00718.91
8.3.20.0000.00720.38
8.3.10.0080.00020.48
8.3.00.0050.00321.90
8.2.170.0110.00722.96
8.2.160.0110.00422.01
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00421.13
8.2.120.0030.00526.35
8.2.110.0000.00919.24
8.2.100.0030.00918.05
8.2.90.0000.00919.18
8.2.80.0030.00517.97
8.2.70.0060.00317.63
8.2.60.0040.00417.93
8.2.50.0090.00018.09
8.2.40.0000.00820.72
8.2.30.0030.00519.40
8.2.20.0000.00817.84
8.2.10.0040.00418.14
8.2.00.0090.00018.14
8.1.270.0110.00421.94
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0030.00622.61
8.1.230.0080.00417.83
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0040.00817.35
8.1.190.0000.00817.36
8.1.180.0040.00418.10
8.1.170.0040.00418.55
8.1.160.0070.00020.90
8.1.150.0080.00018.97
8.1.140.0040.00419.52
8.1.130.0030.00317.73
8.1.120.0050.00317.53
8.1.110.0040.00417.45
8.1.100.0040.00417.48
8.1.90.0040.00417.48
8.1.80.0030.00517.33
8.1.70.0070.00017.38
8.1.60.0000.00817.62
8.1.50.0030.00617.56
8.1.40.0000.00917.51
8.1.30.0030.00517.64
8.1.20.0040.00417.39
8.1.10.0000.00817.55
8.1.00.0040.00417.50
8.0.300.0000.00818.77
8.0.290.0050.00216.63
8.0.280.0000.00718.52
8.0.270.0000.00717.27
8.0.260.0000.00617.24
8.0.250.0060.00317.06
8.0.240.0060.00317.11
8.0.230.0040.00417.11
8.0.220.0050.00317.00
8.0.210.0030.00316.98
8.0.200.0060.00017.01
8.0.190.0040.00417.07
8.0.180.0030.00617.03
8.0.170.0000.00717.01
8.0.160.0030.00517.00
8.0.150.0000.00717.01
8.0.140.0040.00416.89
8.0.130.0050.00013.43
8.0.120.0000.00716.86
8.0.110.0070.00016.82
8.0.100.0030.00617.04
8.0.90.0040.00416.87
8.0.80.0040.01116.90
8.0.70.0070.00016.96
8.0.60.0070.00017.03
8.0.50.0050.00217.09
8.0.30.0090.01117.27
8.0.20.0120.01017.41
8.0.10.0080.00016.98
8.0.00.0050.01216.85
7.4.330.0050.00016.73
7.4.320.0040.00416.60
7.4.300.0000.00616.43
7.4.290.0000.00716.46
7.4.280.0050.00316.63
7.4.270.0030.00316.55
7.4.260.0030.00516.54
7.4.250.0020.00516.50
7.4.240.0000.00716.69
7.4.230.0030.00316.38
7.4.220.0040.01516.49
7.4.210.0040.01616.66
7.4.200.0050.00216.42
7.4.160.0120.00416.75
7.4.150.0190.00017.40
7.4.140.0090.00917.86
7.4.130.0070.01016.66
7.4.120.0150.00416.54
7.4.110.0040.01916.73
7.4.100.0100.01316.39
7.4.90.0150.00316.61
7.4.80.0150.00619.39
7.4.70.0090.01316.55
7.4.60.0140.00316.63
7.4.50.0100.00716.59
7.4.40.0140.00316.45
7.4.30.0030.02216.86
7.4.00.0040.01214.96
7.3.330.0000.00613.17
7.3.320.0060.00013.34
7.3.310.0040.00416.29
7.3.300.0070.00016.34
7.3.290.0090.01116.37
7.3.280.0050.01216.40
7.3.270.0070.01717.40
7.3.260.0060.01216.41
7.3.250.0110.00816.47
7.3.240.0080.01016.50
7.3.230.0130.01016.39
7.3.210.0070.01016.52
7.3.200.0030.01316.42
7.3.190.0100.00616.42
7.3.180.0070.01016.50
7.3.170.0060.01116.47
7.3.160.0080.00816.69
7.3.10.0060.00616.73
7.3.00.0020.01116.72
7.2.330.0150.00616.73
7.2.320.0060.01216.81
7.2.310.0080.00816.60
7.2.300.0130.00316.80
7.2.290.0070.01616.68
7.2.130.0080.00716.69
7.2.120.0100.00516.59
7.2.110.0060.00817.09
7.2.100.0110.00416.87
7.2.90.0030.00916.67
7.2.80.0050.00816.99
7.2.70.0060.00816.72
7.2.60.0040.01016.70
7.2.50.0030.00816.78
7.2.40.0080.00716.89
7.2.30.0120.00216.71
7.2.20.0100.00316.95
7.2.10.0080.00716.92
7.2.00.0080.00917.81
7.1.250.0080.00515.57
7.1.240.0110.00415.74
7.1.230.0150.00315.70
7.1.220.0140.00015.84
7.1.210.0090.00615.95
7.1.200.0090.00515.93
7.1.190.0110.00415.71
7.1.180.0100.00615.44
7.1.170.0110.00415.61
7.1.160.0090.00315.45
7.1.150.0090.00615.93
7.1.140.0070.00815.70
7.1.130.0090.00615.71
7.1.120.0080.00615.72
7.1.110.0120.00315.86
7.1.100.0110.00516.65
7.1.90.0090.00615.37
7.1.80.0090.00615.63
7.1.70.0060.00516.24
7.1.60.0070.01417.47
7.1.50.0080.01016.21
7.1.40.0100.00715.77
7.1.30.0090.01315.71
7.1.20.0100.00515.59
7.1.10.0120.00915.77
7.1.00.0080.04018.88
7.0.330.0160.00315.39
7.0.320.0080.00815.37
7.0.310.0090.00315.42
7.0.300.0090.00315.44
7.0.290.0060.00615.49
7.0.280.0120.00315.44
7.0.270.0150.00315.26
7.0.260.0070.00715.50
7.0.250.0070.01115.20
7.0.240.0030.01015.45
7.0.230.0100.00315.37
7.0.220.0040.01115.22
7.0.210.0070.00715.46
7.0.200.0280.00914.98
7.0.190.0150.00915.10
7.0.180.0140.00515.59
7.0.170.0120.00815.61
7.0.160.0120.00515.43
7.0.150.0080.00815.36
7.0.140.0150.00915.43
7.0.130.0160.00415.36
7.0.120.0080.00815.50
7.0.110.0170.00315.09
7.0.100.0080.00815.34
7.0.90.0090.00515.45
7.0.80.0110.00415.52
7.0.70.0070.01315.47
7.0.60.0130.04218.60
7.0.50.0060.04516.65
7.0.40.0040.02916.80
7.0.30.0150.03016.90
7.0.20.0290.03016.88
7.0.10.0080.04616.84
7.0.00.0090.02916.92
5.6.380.0000.01713.98
5.6.370.0110.00314.36
5.6.360.0040.01113.99
5.6.350.0000.01714.21
5.6.340.0100.00014.31
5.6.330.0000.01014.00
5.6.320.0060.00614.00
5.6.310.0040.01113.89
5.6.300.0040.01114.12
5.6.290.0040.00714.29
5.6.280.0020.02617.71
5.6.270.0040.01114.08
5.6.260.0060.00914.17
5.6.250.0000.01514.36
5.6.240.0030.00714.31
5.6.230.0100.00014.33
5.6.220.0050.00514.38
5.6.210.0100.04317.34
5.6.200.0050.04516.18
5.6.190.0110.04517.26
5.6.180.0150.02517.35
5.6.170.0180.04017.21
5.6.160.0050.04517.48
5.6.150.0070.02016.25
5.6.140.0050.03716.18
5.6.130.0080.02116.30
5.6.120.0100.03817.56
5.6.110.0120.04017.71
5.6.100.0070.02017.41
5.6.90.0080.03717.44
5.6.80.0070.03917.25
5.6.70.0030.00714.11
5.6.60.0090.00313.77
5.6.50.0070.00713.96
5.6.40.0000.00814.02
5.6.30.0040.00413.97
5.6.20.0060.00314.30
5.6.10.0040.00814.14
5.6.00.0040.00814.43
5.5.380.0030.01010.99
5.5.370.0060.00611.07
5.5.360.0030.00610.64
5.5.350.0160.03115.68
5.5.340.0070.02714.43
5.5.330.0080.04115.57
5.5.320.0300.02315.76
5.5.310.0150.04115.64
5.5.300.0040.02214.55
5.5.290.0100.04114.53
5.5.280.0030.04515.91
5.5.270.0080.04215.98
5.5.260.0070.03515.78
5.5.250.0060.04115.79
5.5.240.0050.03015.72
5.5.230.0040.00710.92
5.5.220.0030.00511.02
5.5.210.0040.00810.98
5.5.200.0000.00510.60
5.5.190.0000.00710.94
5.5.180.0100.00010.78
5.5.170.0050.00310.86
5.5.160.0080.00410.70
5.5.150.0030.00511.13
5.5.140.0040.00410.85
5.5.130.0070.00410.97
5.5.120.0070.00711.00
5.5.110.0030.00610.84
5.5.100.0070.00310.80
5.5.90.0000.01110.95
5.5.80.0080.00810.86
5.5.70.0040.00810.63
5.5.60.0030.00910.69
5.5.50.0090.00611.05
5.5.40.0090.00610.93
5.5.30.0060.00310.79
5.5.20.0000.00810.98
5.5.10.0070.00710.75
5.5.00.0070.00310.89

preferences:
46.76 ms | 400 KiB | 5 Q