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) { $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.0000.01516.88
8.3.50.0230.00517.33
8.3.40.0070.01018.81
8.3.30.0150.00018.84
8.3.20.0000.00818.90
8.3.10.0030.00720.53
8.3.00.0030.00619.50
8.2.180.0130.00316.63
8.2.170.0070.00722.96
8.2.160.0120.00620.52
8.2.150.0000.00924.18
8.2.140.0030.00724.66
8.2.130.0040.00426.16
8.2.120.0000.00721.03
8.2.110.0050.00522.23
8.2.100.0090.00317.75
8.2.90.0030.00619.20
8.2.80.0000.00819.40
8.2.70.0060.00317.75
8.2.60.0000.00818.05
8.2.50.0000.00818.07
8.2.40.0080.00018.28
8.2.30.0000.00718.15
8.2.20.0060.00319.48
8.2.10.0050.00317.89
8.2.00.0030.00617.90
8.1.280.0120.00325.92
8.1.270.0000.00923.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.00922.14
8.1.230.0090.00319.22
8.1.220.0030.00617.74
8.1.210.0000.00818.77
8.1.200.0030.00717.25
8.1.190.0040.00417.52
8.1.180.0050.00318.10
8.1.170.0030.00619.00
8.1.160.0110.00018.93
8.1.150.0040.00418.64
8.1.140.0040.00417.42
8.1.130.0050.00217.79
8.1.120.0070.00017.56
8.1.110.0040.00417.54
8.1.100.0050.00217.54
8.1.90.0040.00417.41
8.1.80.0000.00817.57
8.1.70.0040.00417.24
8.1.60.0050.00317.73
8.1.50.0030.00517.54
8.1.40.0030.00617.53
8.1.30.0040.00417.56
8.1.20.0000.00817.77
8.1.10.0000.00717.65
8.1.00.0040.00417.57
8.0.300.0040.00419.82
8.0.290.0070.00016.75
8.0.280.0030.00318.54
8.0.270.0030.00317.41
8.0.260.0000.00716.84
8.0.250.0000.00817.07
8.0.240.0040.00416.91
8.0.230.0000.00717.07
8.0.220.0000.00717.02
8.0.210.0030.00617.04
8.0.200.0090.00016.91
8.0.190.0040.00417.00
8.0.180.0070.00017.02
8.0.170.0090.00016.97
8.0.160.0070.00016.97
8.0.150.0040.00417.00
8.0.140.0120.00016.90
8.0.130.0000.00613.48
8.0.120.0000.00816.85
8.0.110.0040.00417.05
8.0.100.0050.00216.86
8.0.90.0000.00716.99
8.0.80.0070.00916.94
8.0.70.0020.00517.02
8.0.60.0040.00416.97
8.0.50.0040.00416.97
8.0.30.0150.00317.40
8.0.20.0070.01217.41
8.0.10.0000.00717.16
8.0.00.0100.01117.00
7.4.330.0050.00013.08
7.4.320.0070.00016.66
7.4.300.0000.00716.59
7.4.290.0070.00016.56
7.4.280.0060.00316.52
7.4.270.0040.00416.59
7.4.260.0030.00313.29
7.4.250.0000.00816.57
7.4.240.0030.00516.74
7.4.230.0000.00816.79
7.4.220.0060.01216.70
7.4.210.0090.00616.63
7.4.200.0000.00716.54
7.4.190.0040.00416.50
7.4.160.0070.01016.62
7.4.150.0140.00316.40
7.4.140.0030.01316.58
7.4.130.0060.01216.75
7.4.120.0090.00916.56
7.4.110.0130.00316.64
7.4.100.0040.01416.58
7.4.90.0130.00316.43
7.4.80.0070.01619.39
7.4.70.0090.00916.52
7.4.60.0110.00516.63
7.4.50.0000.00916.63
7.4.40.0070.00716.39
7.4.30.0090.00616.54
7.4.00.0040.01214.98
7.3.330.0000.00613.32
7.3.320.0030.00313.27
7.3.310.0040.00416.43
7.3.300.0070.00016.39
7.3.290.0100.00616.54
7.3.280.0110.00816.42
7.3.270.0100.01016.50
7.3.260.0120.00616.51
7.3.250.0090.01216.54
7.3.240.0030.01316.68
7.3.230.0120.00616.45
7.3.210.0070.01016.70
7.3.200.0100.01016.36
7.3.190.0120.00416.46
7.3.180.0070.01016.62
7.3.170.0140.00716.60
7.3.160.0080.00816.45
7.3.120.0000.01014.88
7.3.10.0060.00616.45
7.3.00.0060.00616.66
7.2.330.0120.00616.81
7.2.320.0140.00316.84
7.2.310.0090.00816.85
7.2.300.0110.00716.79
7.2.290.0150.00916.58
7.2.130.0070.00717.02
7.2.120.0130.00017.11
7.2.110.0080.00317.12
7.2.100.0030.00816.68
7.2.90.0030.01016.98
7.2.80.0000.01217.12
7.2.70.0070.00716.80
7.2.60.0070.00616.68
7.2.50.0000.00916.85
7.2.40.0100.00716.96
7.2.30.0070.00716.85
7.2.20.0040.01417.06
7.2.10.0060.00617.02
7.2.00.0120.00318.16
7.1.250.0060.00915.80
7.1.200.0080.00815.76
7.1.100.0060.00618.17
7.1.70.0190.00316.92
7.1.60.0130.01019.30
7.1.50.0030.01634.87
7.1.00.0030.03722.46
7.0.200.0070.00016.55
7.0.140.0000.08022.15
7.0.120.0070.07022.18
7.0.60.0000.04719.95
7.0.50.0030.07317.90
7.0.40.0030.08717.79
7.0.30.0030.06317.75
7.0.20.0070.08717.73
7.0.10.0070.07717.86
7.0.00.0130.07717.76
5.6.280.0000.07321.11
5.6.210.0100.08320.74
5.6.200.0030.04318.29
5.6.190.0130.04018.19
5.6.180.0100.07318.17
5.6.170.0030.08318.24
5.6.160.0100.08018.16
5.6.150.0070.07318.23
5.6.140.0070.06718.13
5.6.130.0000.06018.15
5.6.120.0070.07318.23
5.6.110.0000.09018.18
5.6.100.0100.07718.14
5.6.90.0130.05318.14
5.6.80.0030.05017.66
5.6.70.0000.06317.53
5.6.60.0130.06017.54
5.6.50.0070.07717.57
5.6.40.0030.08717.50
5.6.30.0100.07717.57
5.6.20.0070.08017.56
5.6.10.0030.04017.54
5.6.00.0100.06717.50
5.5.350.0070.06020.41
5.5.340.0070.06318.09
5.5.330.0070.07718.07
5.5.320.0170.07017.96
5.5.310.0100.05017.98
5.5.300.0070.04018.07
5.5.290.0000.08717.95
5.5.280.0170.06717.98
5.5.270.0100.07718.08
5.5.260.0070.07017.92
5.5.250.0070.04717.79
5.5.240.0030.07317.38
5.5.230.0070.08017.46
5.5.220.0170.06317.36
5.5.210.0000.06317.48
5.5.200.0100.06317.34
5.5.190.0030.08017.37
5.5.180.0070.08317.43
5.5.160.0070.05017.32
5.5.150.0000.04717.30
5.5.140.0000.04317.33
5.5.130.0000.06717.43
5.5.120.0100.07317.44
5.5.110.0070.04017.29
5.5.100.0070.05717.31
5.5.90.0070.05017.33
5.5.80.0030.05717.21
5.5.70.0100.07317.19
5.5.60.0070.06317.22
5.5.50.0100.06317.27
5.5.40.0030.08017.23
5.5.30.0000.05017.22
5.5.20.0070.05717.18
5.5.10.0070.04317.21
5.5.00.0100.05717.32
5.4.450.0070.05019.45
5.4.440.0070.08719.44
5.4.430.0070.07319.35
5.4.420.0000.08319.51
5.4.410.0030.08319.31
5.4.400.0070.06019.08
5.4.390.0070.03718.95
5.4.380.0130.06719.07
5.4.370.0070.07719.20
5.4.360.0100.03719.16
5.4.350.0070.06719.04
5.4.340.0130.07019.07
5.4.320.0100.04019.20
5.4.310.0130.07019.14
5.4.300.0170.06719.03
5.4.290.0170.06719.05
5.4.280.0130.07019.07
5.4.270.0030.07019.04
5.4.260.0100.04019.10
5.4.250.0030.04719.05
5.4.240.0100.07019.11
5.4.230.0030.05718.94
5.4.220.0100.05719.04
5.4.210.0000.06019.10
5.4.200.0130.07319.00
5.4.190.0000.05319.09
5.4.180.0030.05319.02
5.4.170.0100.06319.04
5.4.160.0000.08019.09
5.4.150.0130.06019.25
5.4.140.0130.06316.42
5.4.130.0100.05716.39
5.4.120.0000.08016.50
5.4.110.0070.07316.60
5.4.100.0000.05316.40
5.4.90.0000.06316.52
5.4.80.0070.05716.57
5.4.70.0130.06016.50
5.4.60.0030.07716.55
5.4.50.0100.07316.27
5.4.40.0070.05316.57
5.4.30.0070.07316.41
5.4.20.0030.04716.55
5.4.10.0000.06716.32
5.4.00.0130.06315.80
5.3.290.0070.08014.71
5.3.280.0030.06314.64
5.3.270.0070.07314.54
5.3.260.0070.07314.68
5.3.250.0070.05714.84
5.3.240.0070.06714.73
5.3.230.0000.06014.68
5.3.220.0070.07314.60
5.3.210.0070.05314.70
5.3.200.0130.04314.50
5.3.190.0130.07014.64
5.3.180.0100.04314.64
5.3.170.0070.07314.58
5.3.160.0100.07714.79
5.3.150.0030.06714.68
5.3.140.0030.08314.63
5.3.130.0100.07714.60
5.3.120.0100.06714.59
5.3.110.0170.07014.67
5.3.100.0030.07713.96
5.3.90.0000.06714.17
5.3.80.0070.05014.05
5.3.70.0070.03714.13
5.3.60.0030.04014.01
5.3.50.0130.07314.06
5.3.40.0030.04013.95
5.3.30.0000.07713.98
5.3.20.0030.06013.72
5.3.10.0100.07013.56
5.3.00.0030.04013.86
5.2.170.0030.03011.00
5.2.160.0030.03011.22
5.2.150.0070.04311.16
5.2.140.0170.05011.00
5.2.130.0030.04011.33
5.2.120.0100.05011.15
5.2.110.0070.04711.13
5.2.100.0000.03710.96
5.2.90.0070.06011.32
5.2.80.0030.05011.08
5.2.70.0070.05011.13
5.2.60.0030.03711.27
5.2.50.0000.03310.92
5.2.40.0070.02711.23
5.2.30.0030.03310.86
5.2.20.0070.03011.01
5.2.10.0070.03010.87
5.2.00.0100.03010.93
5.1.60.0070.05010.05
5.1.50.0070.0539.95
5.1.40.0070.04710.07
5.1.30.0070.04010.32
5.1.20.0030.05710.33
5.1.10.0030.0409.92
5.1.00.0070.03010.11
5.0.50.0030.0338.60
5.0.40.0000.0478.49
5.0.30.0070.0508.28
5.0.20.0000.0508.24
5.0.10.0000.0208.09
5.0.00.0030.0378.14
4.4.90.0030.0277.74
4.4.80.0000.0177.74
4.4.70.0000.0277.74
4.4.60.0030.0277.74
4.4.50.0000.0237.74
4.4.40.0000.0577.74
4.4.30.0030.0337.74
4.4.20.0000.0277.74
4.4.10.0000.0177.74
4.4.00.0000.0577.74
4.3.110.0030.0177.74
4.3.100.0000.0207.74
4.3.90.0030.0337.74
4.3.80.0030.0537.74
4.3.70.0000.0377.74
4.3.60.0070.0237.74
4.3.50.0030.0177.74
4.3.40.0000.0537.74
4.3.30.0030.0237.74
4.3.20.0000.0377.74
4.3.10.0000.0377.74
4.3.00.0000.0337.74

preferences:
36.69 ms | 401 KiB | 5 Q