3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cart { const PRICE_BUTTER = 1.00; const PRICE_MILK = 3.00; const PRICE_EGGS = 6.95; protected $products = array(); public function add($product, $quantity) { $this->products[$product] = $quantity; } public function getQuantity($product) { return isset($this->products[$product]) ? $this->products[$product] : FALSE; } public function getTotal($tax) { $total = 0.00; $callback = function ($quantity, $product) use ($tax, &$total) { $pricePerItem = constant(__CLASS__ . "::PRICE_" . strtoupper($product)); $total += ($pricePerItem * $quantity) * ($tax + 1.0); }; array_walk($this->products, $callback); return round($total, 2); } } $my_cart = new Cart; // Add some items to the cart $my_cart->add('butter', 1); $my_cart->add('milk', 3); // Print the total with a 5% sales tax. print $my_cart->getTotal(0.05) . "\n"; // The result is 54.29 ?>

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.0090.00916.50
8.3.50.0060.00916.42
8.3.40.0130.01021.88
8.3.30.0090.00618.84
8.3.20.0040.00424.18
8.3.10.0000.00724.66
8.3.00.0080.00026.16
8.2.180.0160.00425.92
8.2.170.0070.00718.96
8.2.160.0100.01022.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0000.00826.35
8.2.110.0090.00022.26
8.2.100.0110.00018.03
8.2.90.0040.00419.35
8.2.80.0040.00418.05
8.2.70.0030.00617.50
8.2.60.0030.00617.75
8.2.50.0030.00617.50
8.2.40.0000.00819.91
8.2.30.0080.00018.07
8.2.20.0000.00718.18
8.2.10.0040.00419.26
8.2.00.0050.00219.43
8.1.280.0120.00625.92
8.1.270.0000.00823.99
8.1.260.0000.00828.09
8.1.250.0080.00028.09
8.1.240.0030.00722.08
8.1.230.0040.00721.02
8.1.220.0030.00517.76
8.1.210.0050.00318.77
8.1.200.0000.00817.47
8.1.190.0040.00817.35
8.1.180.0050.00318.10
8.1.170.0040.00418.84
8.1.160.0070.00018.87
8.1.150.0020.00518.92
8.1.140.0070.00019.03
8.1.130.0000.00717.52
8.1.120.0030.00417.50
8.1.110.0050.00217.54
8.1.100.0040.00417.54
8.1.90.0070.00017.49
8.1.80.0030.00717.55
8.1.70.0030.00317.55
8.1.60.0050.00517.55
8.1.50.0080.00017.60
8.1.40.0030.00617.63
8.1.30.0030.00517.72
8.1.20.0030.00517.62
8.1.10.0030.00717.59
8.1.00.0050.00317.46
8.0.300.0040.00419.62
8.0.290.0000.00716.75
8.0.280.0030.00318.59
8.0.270.0000.00818.00
8.0.260.0030.00316.93
8.0.250.0000.00717.01
8.0.240.0000.00617.04
8.0.230.0000.00617.04
8.0.220.0040.00316.94
8.0.210.0000.00716.92
8.0.200.0000.00617.04
8.0.190.0030.00317.02
8.0.180.0000.00816.92
8.0.170.0030.00617.01
8.0.160.0050.00216.96
8.0.150.0050.00216.98
8.0.140.0000.00716.90
8.0.130.0000.00613.44
8.0.120.0000.01016.84
8.0.110.0000.00716.78
8.0.100.0070.00016.97
8.0.90.0000.00816.94
8.0.80.0030.01716.90
8.0.70.0040.00416.85
8.0.60.0040.00416.95
8.0.50.0030.00517.02
8.0.30.0140.00317.03
8.0.20.0130.00917.36
8.0.10.0050.00217.04
8.0.00.0180.00016.77
7.4.330.0040.00015.55
7.4.320.0030.00316.63
7.4.300.0070.00016.60
7.4.290.0080.00016.42
7.4.280.0000.00716.48
7.4.270.0000.00816.68
7.4.260.0000.00513.25
7.4.250.0040.00416.57
7.4.240.0030.00316.49
7.4.230.0070.00016.51
7.4.220.0020.00516.43
7.4.210.0080.00816.64
7.4.200.0070.00016.68
7.4.130.0070.01016.61
7.4.120.0090.00916.64
7.4.110.0120.01116.55
7.4.100.0150.00616.44
7.4.90.0130.00916.47
7.4.80.0130.00716.39
7.4.70.0090.01216.47
7.4.60.0120.01016.51
7.4.50.0130.00916.56
7.4.40.0140.01016.50
7.4.30.0150.00916.57
7.4.20.0120.01116.45
7.4.10.0130.01016.48
7.4.00.0150.00516.66
7.3.330.0050.00316.50
7.3.320.0030.00313.30
7.3.310.0070.00016.41
7.3.300.0030.00316.50
7.3.290.0050.01016.44
7.3.260.0060.01116.72
7.3.240.0130.01016.55
7.3.230.0130.00816.47
7.3.220.0140.00916.52
7.3.210.0120.01016.42
7.3.200.0120.01116.45
7.3.190.0110.01116.32
7.3.180.0150.00716.52
7.3.170.0140.00916.54
7.3.160.0160.00716.50
7.3.150.0150.01016.57
7.3.140.0120.01116.46
7.3.130.0200.00516.61
7.3.120.0170.00616.52
7.3.110.0150.00816.45
7.3.100.0160.00816.54
7.3.90.0090.01216.42
7.3.80.0130.00816.44
7.3.70.0150.00916.46
7.3.60.0110.01016.51
7.3.50.0140.01016.50
7.3.40.0100.01316.41
7.3.30.0140.00916.47
7.3.20.0130.01116.48
7.3.10.0140.00916.45
7.3.00.0200.00916.44
7.2.340.0110.01116.68
7.2.330.0090.01116.67
7.2.320.0090.01216.54
7.2.310.0110.01116.62
7.2.300.0140.00916.80
7.2.290.0130.01016.62
7.2.280.0150.00716.80
7.2.270.0190.00416.71
7.2.260.0150.00916.74
7.2.250.0150.00916.64
7.2.240.0160.00616.77
7.2.230.0140.00816.63
7.2.220.0160.00716.76
7.2.210.0140.00916.65
7.2.200.0160.00716.72
7.2.190.0140.00916.71
7.2.180.0170.00616.69
7.2.170.0080.01416.67
7.2.160.0100.01416.64
7.2.150.0130.01016.73
7.2.140.0200.01416.71
7.2.130.0100.01116.69
7.2.120.0140.01016.70
7.2.110.0150.00816.70
7.2.100.0120.01116.75
7.2.90.0130.01016.77
7.2.80.0140.00916.58
7.2.70.0160.00916.68
7.2.60.0170.00816.72
7.2.50.0180.00816.61
7.2.40.0170.00716.73
7.2.30.0150.00916.67
7.2.20.0120.00916.55
7.2.10.0110.01016.69
7.2.00.0100.01216.52
7.1.330.0210.01115.61
7.1.320.0240.00915.79
7.1.310.0200.01715.69
7.1.300.0250.00915.64
7.1.290.0320.01015.76
7.1.280.0210.00915.77
7.1.270.0160.01415.63
7.1.260.0290.00715.65
7.1.250.0180.01115.77
7.1.240.0210.00915.63
7.1.230.0220.00815.58
7.1.220.0180.01115.67
7.1.210.0210.01015.78
7.1.200.0210.01115.72
7.1.190.0810.00715.71
7.1.180.0210.01215.71
7.1.170.0220.00915.74
7.1.160.0340.00915.69
7.1.150.0220.00815.79
7.1.140.0220.00615.64
7.1.130.0230.01215.66
7.1.120.0220.01215.74
7.1.110.0260.00915.63
7.1.100.0230.00715.76
7.1.90.0430.00815.57
7.1.80.0240.00615.57
7.1.70.0260.00815.74
7.1.60.0220.00815.69
7.1.50.0270.01015.53
7.1.40.0210.01315.67
7.1.30.0230.00915.75
7.1.20.0390.00215.67
7.1.10.0420.01315.75
7.1.00.0210.01015.69
7.0.330.0230.00615.24
7.0.320.0280.00415.46
7.0.310.0250.00715.32
7.0.300.0210.00915.33
7.0.290.0230.00515.39
7.0.280.0230.00515.26
7.0.270.0290.01215.39
7.0.260.0240.00615.31
7.0.250.0290.00715.35
7.0.240.0170.01115.46
7.0.230.0220.00715.36
7.0.220.0260.00815.41
7.0.210.0190.00915.28
7.0.200.0280.00715.46
7.0.190.0220.01215.39
7.0.180.0240.00415.37
7.0.170.0210.00715.35
7.0.160.0220.00715.35
7.0.150.0140.01515.43
7.0.140.0200.01215.47
7.0.130.0340.00815.54
7.0.120.0230.00715.42
7.0.110.0250.00615.40
7.0.100.0270.00615.38
7.0.90.0180.01315.37
7.0.80.0210.01115.41
7.0.70.0280.00415.39
7.0.60.0280.00815.35
7.0.50.0180.01115.30
7.0.40.0230.00815.42
7.0.30.0160.01615.36
7.0.20.0210.01015.41
7.0.10.0290.02015.30
7.0.00.0370.00915.38
5.6.400.0190.01815.96
5.6.390.0190.01416.16
5.6.380.0130.01716.12
5.6.370.0220.01116.09
5.6.360.0230.00916.18
5.6.350.0250.00516.26
5.6.340.0190.01115.95
5.6.330.0250.00716.14
5.6.320.0220.00716.28
5.6.310.0160.01416.00
5.6.300.0220.01316.06
5.6.290.0210.01116.26
5.6.280.0160.01416.11
5.6.270.0200.00916.16
5.6.260.0190.01616.08
5.6.250.0230.00916.08
5.6.240.0180.01216.05
5.6.230.0170.01516.22
5.6.220.0210.00916.03
5.6.210.0110.02016.07
5.6.200.0240.01016.19
5.6.190.0230.01216.10
5.6.180.0270.00916.11
5.6.170.0270.00916.15
5.6.160.0280.01016.15
5.6.150.0290.00916.24
5.6.140.0240.00916.05
5.6.130.0230.01316.08
5.6.120.0230.01016.25
5.6.110.0260.01116.21
5.6.100.0240.00916.09
5.6.90.0300.00916.20
5.6.80.0150.01616.08
5.6.70.0220.01316.19
5.6.60.0150.01215.95
5.6.50.0220.01016.00
5.6.40.0220.00815.91
5.6.30.0220.00915.95
5.6.20.0140.01715.95
5.6.10.0190.01116.11
5.6.00.0180.01416.11
5.5.380.0270.00716.16
5.5.370.0230.01016.07
5.5.360.0230.01016.07
5.5.350.0350.01216.03
5.5.340.0220.01315.97
5.5.330.0170.01616.11
5.5.320.0250.01215.92
5.5.310.0240.01216.10
5.5.300.0170.01616.09
5.5.290.0180.01716.21
5.5.280.0280.00616.05
5.5.270.0220.01216.24
5.5.260.0270.00915.89
5.5.250.0250.01215.83
5.5.240.0220.01116.19
5.5.230.0190.01515.92
5.5.220.0180.01216.01
5.5.210.0200.01216.11
5.5.200.0200.01415.94
5.5.190.0290.01515.98
5.5.180.0210.00916.13
5.5.170.0180.01115.97
5.5.160.0230.01116.04
5.5.150.0220.00915.89
5.5.140.0200.01116.09
5.5.130.0220.01016.17
5.5.120.0170.01316.05
5.5.110.0190.01116.00
5.5.100.0160.01416.14
5.5.90.0200.00915.94
5.5.80.0160.01116.11
5.5.70.0150.01415.99
5.5.60.0130.01616.12
5.5.50.0130.01416.09
5.5.40.0200.00616.03
5.5.30.0200.00915.88
5.5.20.0140.01216.09
5.5.10.0170.01015.89
5.5.00.0160.01315.90
5.4.450.0230.00714.22
5.4.440.0140.00914.22
5.4.430.0140.01014.22
5.4.420.0160.00814.22
5.4.410.0190.00814.22
5.4.400.0240.00414.22
5.4.390.0170.00914.22
5.4.380.0160.00814.22
5.4.370.0170.00714.22
5.4.360.0230.00214.22
5.4.350.0180.01114.22
5.4.340.0160.00814.22
5.4.330.0090.01314.22
5.4.320.0160.00714.22
5.4.310.0180.00714.22
5.4.300.0150.01114.22
5.4.290.0140.01014.22
5.4.280.0240.00514.22
5.4.270.0150.00814.22
5.4.260.0160.00614.22
5.4.250.0180.00414.22
5.4.240.0100.01514.22
5.4.230.0110.01114.22
5.4.220.0110.01114.22
5.4.210.0180.00414.22
5.4.200.0190.00214.22
5.4.190.0190.00314.22
5.4.180.0140.00814.22
5.4.170.0140.00714.22
5.4.160.0150.00814.22
5.4.150.0190.00314.22
5.4.140.0150.00814.22
5.4.130.0150.01014.22
5.4.120.0150.00614.22
5.4.110.0120.01014.22
5.4.100.0150.00614.22
5.4.90.0140.00814.22
5.4.80.0210.00214.22
5.4.70.0240.00614.22
5.4.60.0190.00914.22
5.4.50.0170.00614.22
5.4.40.0160.00614.22
5.4.30.0100.01314.22
5.4.20.0120.01014.22
5.4.10.0160.00614.22
5.4.00.0170.00614.22
5.3.290.0130.01214.22
5.3.280.0150.00714.22
5.3.270.0220.01114.22
5.3.260.0220.00714.22
5.3.250.0160.00614.22
5.3.240.0220.00814.22
5.3.230.0140.01014.22
5.3.220.0150.00914.22
5.3.210.0180.00814.22
5.3.200.0130.01114.22
5.3.190.0130.01114.22
5.3.180.0210.00914.22
5.3.170.0140.01214.22
5.3.160.0200.00614.22
5.3.150.0200.00514.22
5.3.140.0170.00714.22
5.3.130.0200.00514.22
5.3.120.0130.01114.22
5.3.110.0130.01214.22
5.3.100.0120.01014.22
5.3.90.0110.01214.22
5.3.80.0150.00914.22
5.3.70.0220.00614.22
5.3.60.0120.01014.22
5.3.50.0190.00814.22
5.3.40.0140.01114.22
5.3.30.0160.01014.22
5.3.20.0140.01014.22
5.3.10.0170.00814.22
5.3.00.0170.00714.22
5.2.170.0100.00914.22
5.2.160.0160.00314.22
5.2.150.0130.01114.22
5.2.140.0060.01414.22
5.2.130.0200.00114.22
5.2.120.0110.00914.22
5.2.110.0100.01014.22
5.2.100.0190.00514.22
5.2.90.0100.00814.22
5.2.80.0100.01114.22
5.2.70.0150.00514.22
5.2.60.0140.00714.22
5.2.50.0130.00814.22
5.2.40.0080.01114.22
5.2.30.0080.01114.22
5.2.20.0160.00614.22
5.2.10.0110.00914.22
5.2.00.0090.00914.22
5.1.60.0100.00714.22
5.1.50.0140.00414.22
5.1.40.0130.00514.22
5.1.30.0110.00814.22
5.1.20.0100.00914.22
5.1.10.0110.00614.22
5.1.00.0110.00714.22
5.0.50.0110.00514.22
5.0.40.0110.00414.22
5.0.30.0100.00914.22
5.0.20.0140.00314.22
5.0.10.0140.00414.22
5.0.00.0090.00814.22
4.4.90.0110.00314.22
4.4.80.0060.00414.22
4.4.70.0040.00414.22
4.4.60.0000.00914.22
4.4.50.0080.00014.22
4.4.40.0090.00014.22
4.4.30.0000.01014.22
4.4.20.0090.00114.22
4.4.10.0050.00514.22
4.4.00.0050.00714.22
4.3.110.0080.00214.22
4.3.100.0030.00714.22
4.3.90.0110.00014.22
4.3.80.0040.00514.22
4.3.70.0070.00314.22
4.3.60.0060.00414.22
4.3.50.0060.00414.22
4.3.40.0060.00214.22
4.3.30.0050.00314.22
4.3.20.0080.00514.22
4.3.10.0060.00114.22
4.3.00.0060.00214.22

preferences:
37.88 ms | 400 KiB | 5 Q