3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CartEntry { //changing to private private $Price; private $Quantity; public function __construct($Price, $Quantity) { $this->Price = $Price; $this->Quantity = $Quantity; } public function ReturnPrice() { return $this->Price; } public function ReturnQuantity() { return $this->Quantity; } }// end class class CartContents { //Changed to private private $items = array(); public function __construct($items) { $this->items = $items; } public function ReturnItems() { return $this->items; } } // end class class Order { private $cart; private $salesTax; function __construct( float $salesTax, Array $items){ $this->salesTax = $salesTax; $this->items = $items; } function OrderTotal() { $cartTotal = 0; for ($i=0, $max=count($this->items); $i < $max; $i++) { $cartTotal += $this->items[$i]->ReturnPrice() * $this->items[$i]->ReturnQuantity(); } $cartTotal += $cartTotal * $this->salesTax; return $cartTotal; } } $entry1 = new CartEntry(1.2, 120); $entry2 = new CartEntry(2.2,200); $mycart = new CartContents([$entry1,$entry2]); $items = $mycart->ReturnItems(); $mytax = 0.2; //Items variable can be changed with mycart $myorder = new Order($mytax,$items); echo $myorder->OrderTotal();

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.80.0030.00616.75
8.3.70.0110.00716.75
8.3.60.0060.00918.55
8.3.50.0050.00916.72
8.3.40.0110.00318.75
8.3.30.0110.00418.76
8.3.20.0040.00420.89
8.3.10.0040.00423.48
8.3.00.0080.00022.46
8.2.200.0030.00718.54
8.2.190.0090.00616.63
8.2.180.0090.00925.92
8.2.170.0170.00319.04
8.2.160.0100.00622.96
8.2.150.0070.00024.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0040.00419.48
8.2.110.0100.00022.25
8.2.100.0080.00417.84
8.2.90.0050.00318.03
8.2.80.0040.00419.22
8.2.70.0040.00417.63
8.2.60.0000.00817.63
8.2.50.0000.00817.55
8.2.40.0000.00819.33
8.2.30.0040.00419.32
8.2.20.0040.00418.14
8.2.10.0060.00319.21
8.2.00.0040.00418.32
8.1.290.0100.00018.88
8.1.280.0060.01225.92
8.1.270.0060.00320.64
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0040.00423.84
8.1.230.0110.00022.66
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0090.00017.36
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0080.00018.50
8.1.160.0000.00818.91
8.1.150.0000.00719.04
8.1.140.0000.00719.00
8.1.130.0000.00920.15
8.1.120.0030.00517.53
8.1.110.0070.00017.46
8.1.100.0040.00417.42
8.1.90.0000.00717.46
8.1.80.0000.00817.47
8.1.70.0050.00217.50
8.1.60.0060.00317.64
8.1.50.0000.01017.43
8.1.40.0060.00317.44
8.1.30.0040.00417.60
8.1.20.0060.00317.64
8.1.10.0000.00817.54
8.1.00.0030.00617.57
8.0.300.0030.00620.07
8.0.290.0000.01016.75
8.0.280.0030.00518.34
8.0.270.0030.00317.14
8.0.260.0000.00618.46
8.0.250.0040.00416.98
8.0.240.0000.00616.97
8.0.230.0000.00816.89
8.0.220.0040.00416.79
8.0.210.0030.00316.84
8.0.200.0030.00316.98
8.0.190.0050.00316.95
8.0.180.0050.00316.98
8.0.170.0080.00016.97
8.0.160.0000.00716.83
8.0.150.0020.00516.89
8.0.140.0000.00716.83
8.0.130.0000.00713.27
8.0.120.0040.00416.89
8.0.110.0040.00416.88
8.0.100.0000.00816.73
8.0.90.0040.00416.93
8.0.80.0100.00716.93
8.0.70.0040.00416.69
8.0.60.0000.00716.80
8.0.50.0080.00016.72
8.0.30.0070.01217.30
8.0.20.0030.01517.32
8.0.10.0040.00417.09
8.0.00.0120.00816.76
7.4.330.0000.00616.74
7.4.320.0020.00516.57
7.4.300.0000.00616.50
7.4.290.0090.00016.59
7.4.280.0080.00016.62
7.4.270.0000.00616.54
7.4.260.0000.00716.60
7.4.250.0070.00016.46
7.4.240.0050.00316.56
7.4.230.0080.00016.72
7.4.220.0040.00416.27
7.4.210.0090.00716.61
7.4.200.0000.00716.62
7.4.160.0110.00516.56
7.4.140.0130.01117.86
7.4.130.0100.00716.65
7.4.120.0140.00416.55
7.4.110.0060.01016.74
7.4.100.0100.00716.54
7.4.90.0120.00916.61
7.4.80.0100.01119.39
7.4.70.0130.00416.46
7.4.60.0130.01016.39
7.4.50.0100.00616.35
7.4.40.0100.00716.57
7.4.10.0070.01015.15
7.4.00.0090.00814.85
7.3.330.0050.00013.34
7.3.320.0050.00013.36
7.3.310.0030.00316.41
7.3.300.0000.00716.29
7.3.290.0040.00416.33
7.3.280.0070.00916.26
7.3.260.0080.01016.44
7.3.240.0100.00716.48
7.3.230.0140.00316.50
7.3.210.0040.01216.35
7.3.200.0080.00816.49
7.3.190.0100.00716.56
7.3.180.0000.01716.54
7.3.170.0160.00716.62
7.3.160.0080.00816.30
7.3.130.0110.00714.93
7.3.120.0100.00714.89
7.3.110.0050.01314.91
7.3.100.0050.00914.78
7.3.90.0080.00715.00
7.3.80.0030.01115.00
7.3.70.0040.00714.98
7.3.60.0030.00714.72
7.3.50.0100.00514.85
7.3.40.0020.01314.92
7.3.30.0090.00614.79
7.3.20.0290.00715.98
7.3.10.0280.00816.07
7.3.00.0260.00916.03
7.2.330.0130.00316.80
7.2.320.0030.01616.94
7.2.310.0070.01016.71
7.2.300.0140.00316.46
7.2.290.0070.01016.61
7.2.260.0040.01514.79
7.2.250.0040.01114.93
7.2.240.0070.01115.08
7.2.230.0100.00515.19
7.2.220.0080.00415.22
7.2.210.0090.00615.11
7.2.200.0060.00715.08
7.2.190.0060.01115.11
7.2.180.0030.00915.08
7.2.170.0060.00615.14
7.2.160.0050.01315.05
7.2.150.0370.00515.89
7.2.140.0340.00616.05
7.2.130.0340.01215.95
7.2.120.0660.01216.07
7.2.110.0300.00815.75
7.2.100.0380.00515.97
7.2.90.0370.00316.03
7.2.80.0480.00715.97
7.2.70.0490.00815.88
7.2.60.0420.00915.90
7.2.50.0430.00715.93
7.2.40.0490.00716.04
7.2.30.0460.01415.99
7.2.20.0430.00816.00
7.2.10.0430.00816.12
7.2.00.0380.00615.99
7.1.330.0040.01015.80
7.1.320.0060.00815.98
7.1.310.0090.00515.90
7.1.300.0050.00815.87
7.1.290.0080.00815.58
7.1.280.0060.00315.75
7.1.270.0290.00515.27
7.1.260.0240.00415.16
7.1.250.0460.00514.85
7.1.240.0110.00415.74
7.1.230.0090.00615.65
7.1.220.0060.00915.75
7.1.210.0060.00615.99
7.1.200.0100.00315.65
7.1.190.0080.00415.96
7.1.180.0030.00615.80
7.1.170.0100.00315.90
7.1.160.0090.00615.93
7.1.150.0000.00815.88
7.1.140.0060.00315.70
7.1.130.0120.00615.61
7.1.120.0100.00316.00
7.1.110.0000.01415.97
7.1.100.0070.01015.86
7.1.90.0040.00716.03
7.1.80.0000.00815.73
7.1.70.0080.00015.90
7.1.60.0000.01515.63
7.1.50.0030.01315.55
7.1.40.0000.01215.54
7.1.30.0030.00615.85
7.1.20.0000.01416.02
7.1.10.0000.01415.70
7.1.00.0040.00415.94

preferences:
65.57 ms | 404 KiB | 6 Q