3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Un panier d'achat simple, qui contient une liste de produits // choisis et la quantité désirée de chaque produit. Il inclut // une méthode qui calcule le prix total des éléments dans le panier // en utilisant une fonction de rappel anonyme. class Panier { const PRICE_BEURRE = 1.00; const PRICE_LAIT = 3.00; const PRICE_OEUF = 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) { $test = $this->$products; $pricePerItem = constant(__CLASS__ . "::PRICE_" . strtoupper($product)); $total += ($pricePerItem * $quantity) * ($tax + 1.0); }; array_walk($this->products, $callback); return round($total, 2); } } $mon_panier = new Panier; // Ajout d'élément au panier $mon_panier->add('beurre', 1); $mon_panier->add('lait', 3); $mon_panier->add('oeuf', 6); // Affichage du prix avec 5.5% de TVA print $mon_panier->getTotal(0.055) . "\n";

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.0110.00416.75
8.3.50.0070.01018.30
8.3.40.0040.01118.92
8.3.30.0120.00319.35
8.3.20.0000.00820.34
8.3.10.0030.00523.61
8.3.00.0050.00319.51
8.2.180.0160.00618.41
8.2.170.0060.00922.96
8.2.160.0060.00920.35
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00022.30
8.2.110.0000.01822.20
8.2.100.0110.00018.03
8.2.90.0000.00918.16
8.2.80.0000.00917.97
8.2.70.0090.00017.75
8.2.60.0050.00318.05
8.2.50.0000.00818.07
8.2.40.0040.00418.47
8.2.30.0070.00318.18
8.2.20.0000.00817.91
8.2.10.0050.00218.20
8.2.00.0030.00517.97
8.1.280.0120.00925.92
8.1.270.0100.01023.91
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00320.95
8.1.230.0060.00620.91
8.1.220.0090.00017.77
8.1.210.0000.00918.97
8.1.200.0060.00317.48
8.1.190.0030.00617.66
8.1.180.0030.00618.10
8.1.170.0080.00018.62
8.1.160.0070.00022.15
8.1.150.0070.00018.69
8.1.140.0020.00517.43
8.1.130.0030.00317.78
8.1.120.0000.00717.55
8.1.110.0040.00417.59
8.1.100.0000.00817.50
8.1.90.0000.00717.54
8.1.80.0040.00417.61
8.1.70.0030.00317.43
8.1.60.0000.00817.67
8.1.50.0000.00817.63
8.1.40.0040.00417.50
8.1.30.0030.00517.78
8.1.20.0040.00417.71
8.1.10.0050.00317.64
8.1.00.0030.00617.63
8.0.300.0000.00720.03
8.0.290.0000.00717.18
8.0.280.0050.00218.45
8.0.270.0030.00517.39
8.0.260.0040.00417.01
8.0.250.0000.00717.02
8.0.240.0030.00317.02
8.0.230.0030.00317.13
8.0.220.0070.00017.02
8.0.210.0070.00017.02
8.0.200.0000.00716.97
8.0.190.0040.00416.98
8.0.180.0050.00317.07
8.0.170.0080.00017.07
8.0.160.0070.00017.05
8.0.150.0040.00416.95
8.0.140.0000.00717.01
8.0.130.0030.00313.48
8.0.120.0040.00417.05
8.0.110.0000.00717.00
8.0.100.0040.00416.92
8.0.90.0070.00016.83
8.0.80.0040.01117.09
8.0.70.0000.00817.06
8.0.60.0000.00717.01
8.0.50.0000.00717.11
8.0.30.0120.01017.18
8.0.20.0060.01217.40
8.0.10.0040.00417.11
8.0.00.0090.01416.84
7.4.330.0000.00515.06
7.4.320.0060.00016.68
7.4.300.0000.00616.51
7.4.290.0030.00516.67
7.4.280.0030.00516.57
7.4.270.0070.00016.70
7.4.260.0070.00016.72
7.4.250.0070.00016.54
7.4.240.0020.00516.61
7.4.230.0000.00716.70
7.4.220.0060.01616.71
7.4.210.0080.00816.70
7.4.200.0070.00016.76
7.4.190.0000.00716.87
7.4.160.0070.01016.67
7.4.150.0080.00917.40
7.4.140.0100.00817.86
7.4.130.0110.00816.64
7.4.120.0020.01616.59
7.4.110.0070.01016.67
7.4.100.0060.01116.63
7.4.90.0110.00616.43
7.4.80.0090.01219.39
7.4.70.0080.00816.73
7.4.60.0070.01016.58
7.4.50.0040.00016.63
7.4.40.0110.00722.77
7.4.30.0120.00916.70
7.4.00.0100.00714.88
7.3.330.0030.00313.38
7.3.320.0030.00313.36
7.3.310.0040.00416.59
7.3.300.0070.00016.51
7.3.290.0140.00716.50
7.3.280.0110.00616.52
7.3.270.0070.01017.40
7.3.260.0070.01016.51
7.3.250.0090.01016.63
7.3.240.0150.00416.68
7.3.230.0070.01016.43
7.3.210.0110.00716.55
7.3.200.0090.01319.39
7.3.190.0140.01016.52
7.3.180.0050.01116.64
7.3.170.0090.00916.50
7.3.160.0040.01716.54
7.3.120.0030.00915.03
7.3.10.0000.01316.74
7.3.00.0100.00316.86
7.2.330.0060.01216.95
7.2.320.0140.00516.75
7.2.310.0090.01316.78
7.2.300.0130.00416.85
7.2.290.0120.00916.64
7.2.130.0120.00016.79
7.2.120.0060.00616.95
7.2.110.0030.01016.74
7.2.100.0030.00916.81
7.2.90.0040.00817.00
7.2.80.0090.00316.69
7.2.70.0070.00716.72
7.2.60.0080.00517.02
7.2.50.0000.01316.82
7.2.40.0000.01316.88
7.2.30.0000.00916.96
7.2.20.0060.00916.85
7.2.10.0030.00616.84
7.2.00.0060.00918.09
7.1.250.0040.01115.78
7.1.200.0040.01115.60
7.1.100.0170.00317.98
7.1.70.0030.00716.93
7.1.60.0170.00719.33
7.1.50.0070.01416.88
7.1.00.0070.07022.51
7.0.200.0030.00616.77
7.0.140.0030.07022.07
7.0.100.0100.04720.07
7.0.90.0130.08720.02
7.0.80.0130.06319.96
7.0.70.0130.04719.94
7.0.60.0130.08319.99
7.0.50.0300.07020.34
7.0.40.0170.07320.14
7.0.30.0030.08320.10
7.0.20.0070.09320.00
7.0.10.0200.04320.09
7.0.00.0100.05020.09
5.6.280.0100.06720.88
5.6.250.0130.04020.83
5.6.240.0000.06320.69
5.6.230.0070.08320.58
5.6.220.0130.07320.51
5.6.210.0030.08320.67
5.6.200.0130.08021.07
5.6.190.0030.05321.05
5.6.180.0030.09020.95
5.6.170.0170.07021.07
5.6.160.0100.06721.07
5.6.150.0170.07021.06
5.6.140.0070.08721.02
5.6.130.0030.08721.07
5.6.120.0170.06721.11
5.6.110.0130.08321.14
5.6.100.0030.08721.08
5.6.90.0070.08720.93
5.6.80.0070.06320.53
5.6.70.0170.03720.33
5.6.60.0070.06020.32
5.6.50.0100.05320.48
5.6.40.0100.06320.46
5.6.30.0070.04720.31
5.6.20.0030.07320.42
5.6.10.0070.06720.33
5.6.00.0100.06020.32
5.5.380.0130.07720.42
5.5.370.0100.06320.36
5.5.360.0000.04720.45
5.5.350.0070.07720.44
5.5.340.0030.08320.88
5.5.330.0030.07720.82
5.5.320.0200.06720.87
5.5.310.0030.08020.93
5.5.300.0070.08020.89
5.5.290.0000.08720.87
5.5.280.0130.07720.92
5.5.270.0070.08320.87
5.5.260.0130.07720.90
5.5.250.0130.07320.63
5.5.240.0170.06720.14
5.5.230.0130.05720.27
5.5.220.0070.07720.25
5.5.210.0070.03720.20
5.5.200.0200.07020.30
5.5.190.0000.06320.29
5.5.180.0100.06720.17
5.5.160.0070.07320.24
5.5.150.0070.04320.12
5.5.140.0070.05320.25
5.5.130.0200.07320.29
5.5.120.0100.08020.00
5.5.110.0100.08720.19
5.5.100.0130.07020.19
5.5.90.0100.07020.17
5.5.80.0100.07020.18
5.5.70.0100.07020.16
5.5.60.0000.04019.94
5.5.50.0130.06020.11
5.5.40.0070.05020.07
5.5.30.0070.08020.05
5.5.20.0030.08320.11
5.5.10.0100.07020.02
5.5.00.0070.08020.10
5.4.450.0030.05319.21
5.4.440.0070.05319.38
5.4.430.0030.05019.37
5.4.420.0030.08319.23
5.4.410.0070.07019.24
5.4.400.0100.05019.10
5.4.390.0070.06718.85
5.4.380.0030.07719.09
5.4.370.0170.03319.13
5.4.360.0130.05319.04
5.4.350.0200.06319.05
5.4.340.0030.04019.05
5.4.320.0170.05318.87
5.4.310.0070.04019.10
5.4.300.0100.04719.21
5.4.290.0070.06319.13
5.4.280.0030.04719.16
5.4.270.0130.03318.95
5.4.260.0130.06719.03
5.4.250.0100.07318.94
5.4.240.0130.03718.85
5.4.230.0070.07319.16
5.4.220.0000.04018.93
5.4.210.0030.06319.09
5.4.200.0100.03319.13
5.4.190.0070.04719.02
5.4.180.0100.07318.94
5.4.170.0100.05719.18
5.4.160.0100.03319.21
5.4.150.0030.08018.88
5.4.140.0170.06316.44
5.4.130.0000.05016.20
5.4.120.0100.07016.45
5.4.110.0000.08016.57
5.4.100.0100.06716.34
5.4.90.0100.05716.54
5.4.80.0130.07016.43
5.4.70.0030.04016.46
5.4.60.0070.06716.36
5.4.50.0000.05016.45
5.4.40.0000.07016.30
5.4.30.0070.04716.47
5.4.20.0030.04316.31
5.4.10.0070.06716.37
5.4.00.0130.06315.83
5.3.290.0130.07714.62
5.3.280.0100.07014.62
5.3.270.0100.05714.61
5.3.260.0170.06714.63
5.3.250.0130.07014.68
5.3.240.0070.03714.55
5.3.230.0030.07014.75
5.3.220.0100.05714.61
5.3.210.0070.07714.59
5.3.200.0000.07714.56
5.3.190.0070.07014.64
5.3.180.0030.05014.69
5.3.170.0030.07714.63
5.3.160.0130.04014.67
5.3.150.0100.04714.59
5.3.140.0070.07314.64
5.3.130.0100.04014.54
5.3.120.0070.06014.63
5.3.110.0030.05014.67
5.3.100.0100.06714.06
5.3.90.0070.07314.16
5.3.80.0200.06014.05
5.3.70.0030.07014.07
5.3.60.0130.07013.98
5.3.50.0130.05314.03
5.3.40.0070.04314.04
5.3.30.0070.07014.06
5.3.20.0170.05313.80
5.3.10.0030.07713.73
5.3.00.0030.07713.71
5.2.170.0030.06711.21
5.2.160.0030.05311.17
5.2.150.0070.06311.21
5.2.140.0030.03311.05
5.2.130.0070.05311.00
5.2.120.0070.06011.19
5.2.110.0000.07011.09
5.2.100.0170.05311.09
5.2.90.0030.06011.12
5.2.80.0100.06711.00
5.2.70.0000.06311.04
5.2.60.0070.05010.99
5.2.50.0000.05010.95
5.2.40.0030.06310.89
5.2.30.0000.06010.90
5.2.20.0030.02311.11
5.2.10.0000.02710.93
5.2.00.0030.06010.71
5.1.60.0030.05710.10
5.1.50.0030.03310.09
5.1.40.0000.05710.08
5.1.30.0000.04710.29
5.1.20.0030.04710.27
5.1.10.0000.04710.15
5.1.00.0030.05710.11
5.0.50.0070.0379.29
5.0.40.0000.0479.29
5.0.30.0100.0509.29
5.0.20.0070.0379.29
5.0.10.0030.0239.29
5.0.00.0070.0609.29
4.4.90.0070.0339.29
4.4.80.0070.0209.29
4.4.70.0030.0339.29
4.4.60.0000.0339.29
4.4.50.0030.0339.29
4.4.40.0000.0479.29
4.4.30.0070.0179.29
4.4.20.0000.0209.29
4.4.10.0000.0439.29
4.4.00.0030.0379.29
4.3.110.0030.0339.29
4.3.100.0000.0279.29
4.3.90.0000.0239.29
4.3.80.0000.0439.29
4.3.70.0000.0309.29
4.3.60.0000.0379.29
4.3.50.0030.0339.29
4.3.40.0030.0539.29
4.3.30.0000.0379.29
4.3.20.0030.0279.29
4.3.10.0000.0379.29
4.3.00.0070.0279.29

preferences:
43.44 ms | 400 KiB | 5 Q