3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Product { protected $price; protected $discount; public function getPrice() { return $this->price->getValue(); } public function setPrice($price, $type) { $this->price = new Price($price); $this->price->setType($type); } public function getDiscount() { return $this->discount->getValue(); } public function setDiscount($discount, $type) { $this->discount = new Discount($discount); $this->discount->setType($type); } } class Price { protected $type; // 0 - one-off price, 1 - monthly price, 2 - combination of previous two; protected $value; function __construct($value) { if (is_numeric($value)) { $this->value = round(floatval($value), 2); } else { $this->value = 0; } } public function getType() { return $this->type; } public function setType($type) { if (is_numeric($type) && in_array(intval($type), array(0, 1, 2))) { $this->type = intval($type); } else { $this->type = 0; } } public function getValue() { return $this->value; } } class Discount extends Price{} class Shopcart { protected $shopping_list; function __construct($products) { $this->shopping_list[] = $products; } public function getTotalPrice() { $cost = 0; foreach ($this->shopping_list as $item) { $cost += $item->getCost(); } return $cost; } }

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.0180.00418.34
8.3.50.0090.01121.21
8.3.40.0040.01118.59
8.3.30.0120.00318.67
8.3.20.0000.00720.36
8.3.10.0000.00823.65
8.3.00.0080.00022.36
8.2.180.0040.01516.50
8.2.170.0120.00622.96
8.2.160.0110.00320.37
8.2.150.0080.00025.66
8.2.140.0000.00824.66
8.2.130.0050.00326.16
8.2.120.0040.00717.50
8.2.110.0090.00019.24
8.2.100.0110.00017.50
8.2.90.0000.00719.05
8.2.80.0000.00817.97
8.2.70.0060.00317.38
8.2.60.0040.00417.80
8.2.50.0060.00318.07
8.2.40.0060.00819.01
8.2.30.0060.00319.79
8.2.20.0100.00217.59
8.2.10.0040.00417.95
8.2.00.0040.00417.98
8.1.280.0130.00725.92
8.1.270.0030.00620.33
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0080.00022.70
8.1.230.0090.00317.42
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0030.00717.35
8.1.190.0000.00817.10
8.1.180.0040.00418.10
8.1.170.0050.00318.46
8.1.160.0040.00423.73
8.1.150.0000.00818.71
8.1.140.0030.00617.33
8.1.130.0040.00417.71
8.1.120.0040.00417.41
8.1.110.0050.00317.43
8.1.100.0000.00717.37
8.1.90.0040.00417.24
8.1.80.0000.00817.40
8.1.70.0000.00817.37
8.1.60.0000.00917.47
8.1.50.0060.00317.42
8.1.40.0030.00717.46
8.1.30.0000.00817.58
8.1.20.0000.00817.61
8.1.10.0050.00217.26
8.1.00.0050.00317.37
8.0.300.0060.00318.77
8.0.290.0070.00316.58
8.0.280.0040.00418.41
8.0.270.0070.00017.16
8.0.260.0030.00317.07
8.0.250.0040.00416.70
8.0.240.0000.00816.88
8.0.230.0070.00016.85
8.0.220.0040.00416.83
8.0.210.0040.00416.71
8.0.200.0000.00716.76
8.0.190.0000.00716.84
8.0.180.0040.00416.82
8.0.170.0030.00516.82
8.0.160.0070.00016.80
8.0.150.0030.00516.74
8.0.140.0000.00716.61
8.0.130.0030.00313.19
8.0.120.0060.00316.82
8.0.110.0040.00416.83
8.0.100.0000.00716.60
8.0.90.0000.00816.59
8.0.80.0100.00616.86
8.0.70.0070.00016.77
8.0.60.0000.00716.85
8.0.50.0060.00316.86
8.0.30.0060.01417.09
8.0.20.0080.01417.40
8.0.10.0040.00416.82
8.0.00.0100.00616.65
7.4.330.0000.00615.08
7.4.320.0040.00416.47
7.4.300.0000.00616.27
7.4.290.0040.00416.42
7.4.280.0080.00016.36
7.4.270.0000.00716.44
7.4.260.0000.00816.41
7.4.250.0000.00716.38
7.4.240.0030.00516.44
7.4.230.0040.00416.60
7.4.220.0130.01016.36
7.4.210.0030.01316.40
7.4.200.0030.00316.31
7.4.160.0060.01116.29
7.4.150.0140.01117.40
7.4.140.0110.00817.86
7.4.130.0100.00716.56
7.4.120.0080.01216.40
7.4.110.0060.01116.32
7.4.100.0200.00316.66
7.4.90.0100.00716.41
7.4.80.0100.01019.39
7.4.70.0120.01216.35
7.4.60.0040.01216.53
7.4.50.0060.00316.64
7.4.40.0090.00916.47
7.4.30.0170.00416.63
7.4.00.0040.01415.09
7.3.330.0000.00513.20
7.3.320.0000.00513.23
7.3.310.0050.00216.19
7.3.300.0000.00616.02
7.3.290.0040.01116.16
7.3.280.0090.00816.19
7.3.270.0030.01417.40
7.3.260.0110.01116.18
7.3.250.0080.01316.26
7.3.240.0070.01716.13
7.3.230.0090.00916.39
7.3.210.0180.00316.14
7.3.200.0080.01019.39
7.3.190.0100.00716.30
7.3.180.0100.00616.32
7.3.170.0130.00716.27
7.3.160.0130.00316.41
7.2.330.0030.01316.32
7.2.320.0060.01116.26
7.2.310.0080.00916.57
7.2.300.0070.01116.54
7.2.290.0100.00716.61
7.2.60.0060.00616.48
7.1.200.0040.00815.70
7.1.70.0000.01517.10
7.1.60.0130.01020.03
7.1.50.0110.01116.91
7.1.00.0030.08722.31
7.0.200.0000.00916.79
7.0.60.0000.04719.82
7.0.50.0070.07717.91
7.0.40.0200.03019.98
7.0.30.0230.06720.13
7.0.20.0070.05020.25
7.0.10.0130.04320.33
7.0.00.0000.04720.08
5.6.280.0030.06021.15
5.6.210.0070.03720.71
5.6.200.0030.08718.16
5.6.190.0070.08720.58
5.6.180.0130.08020.46
5.6.170.0170.04320.58
5.6.160.0100.08020.57
5.6.150.0130.06718.16
5.6.140.0070.08318.14
5.6.130.0030.08718.17
5.6.120.0100.07720.97
5.6.110.0130.05721.01
5.6.100.0130.06021.16
5.6.90.0070.06321.14
5.6.80.0030.08720.44
5.6.70.4070.04020.50
5.5.350.0200.07020.49
5.5.340.0070.08318.02
5.5.330.0100.08720.13
5.5.320.0400.07320.36
5.5.310.0270.05320.29
5.5.300.0000.04317.98
5.5.290.0100.07717.99
5.5.280.0170.07320.79
5.5.270.0070.06020.92
5.5.260.0100.07720.75
5.5.250.0130.07720.51
5.5.240.0300.05720.14
5.4.450.0700.05319.43
5.4.440.0770.05019.50
5.4.430.0730.06019.41
5.4.420.0870.04719.29
5.4.410.0630.06019.40
5.4.400.0800.04319.12
5.4.390.0730.05719.18
5.4.380.0830.04018.78
5.4.370.0630.06319.16
5.4.360.0830.06019.19
5.4.350.0670.05018.95
5.4.340.1000.04319.12
5.4.320.0770.08019.25
5.4.310.0630.05719.21
5.4.300.0770.06318.80
5.4.290.0670.05319.20
5.4.280.0730.05018.77
5.4.270.0670.05319.11
5.4.260.0700.06019.28
5.4.250.0830.04319.15
5.4.240.0670.06318.79
5.4.230.0770.05018.92
5.4.220.0730.05719.16
5.4.210.0800.05018.94
5.4.200.0770.05316.72
5.4.190.0670.06019.21
5.4.180.0770.05319.05
5.4.170.0870.04719.09
5.4.160.0730.05718.94
5.4.150.0800.05319.04
5.4.140.0830.04716.47
5.4.130.0770.05016.62
5.4.120.0700.05316.78
5.4.110.0730.05016.56
5.4.100.0830.04316.62
5.4.90.0770.05016.46
5.4.80.0830.04316.47
5.4.70.0970.06316.36
5.4.60.0000.03316.48
5.4.50.0000.03716.18
5.4.40.0230.03716.39
5.4.30.0370.03016.54
5.4.20.0270.05716.25

preferences:
31.44 ms | 401 KiB | 5 Q