3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Price { protected $value; public function __construct($value) { $this->value = $value; } // Duck typing means this declaration is actually optional abstract protected function getRawValue(); public function getFormattedValue() { // Calls a protected method of whichever child class is $this return number_format($this->getRawValue(), 2); } public function add(Price $other) { // Calls a protected method of whichever child class is $other $this->value += $other->getRawValue(); } } class TaxFreePrice extends Price { protected function getRawValue() { return $this->value; } } class PriceWithTax extends Price{ const TAX_RATE=1.2; protected function getRawValue() { return $this->value * self::TAX_RATE; } } $a = new TaxFreePrice(10); $b = new PriceWithTax(10); echo $a->getFormattedValue(), PHP_EOL; echo $b->getFormattedValue(), PHP_EOL; // Here, an instance of TaxFreePrice will access a protected member of PriceWithTax $a->add($b); echo $a->getFormattedValue(), PHP_EOL;

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.0070.00718.30
8.3.50.0110.00416.39
8.3.40.0090.00619.14
8.3.30.0150.00018.57
8.3.20.0060.00319.31
8.3.10.0040.00421.98
8.3.00.0050.00318.05
8.2.180.0160.00616.75
8.2.170.0140.00022.96
8.2.160.0060.00918.97
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0070.00021.12
8.2.110.0030.00620.51
8.2.100.0090.00317.84
8.2.90.0090.00017.88
8.2.80.0040.00418.94
8.2.70.0000.00818.05
8.2.60.0070.00018.05
8.2.50.0050.00318.10
8.2.40.0000.00819.24
8.2.30.0040.00419.57
8.2.20.0000.00818.11
8.2.10.0080.00418.23
8.2.00.0070.00019.59
8.1.280.0190.00325.92
8.1.270.0050.00324.01
8.1.260.0030.00626.35
8.1.250.0050.00328.09
8.1.240.0000.01024.03
8.1.230.0070.00422.66
8.1.220.0000.00818.73
8.1.210.0000.00818.77
8.1.200.0030.00617.48
8.1.190.0060.00317.25
8.1.180.0040.00418.10
8.1.170.0040.00418.64
8.1.160.0070.00018.89
8.1.150.0000.00718.85
8.1.140.0040.00417.62
8.1.130.0000.00719.04
8.1.120.0000.00717.41
8.1.110.0060.00617.46
8.1.100.0000.00717.52
8.1.90.0040.00417.45
8.1.80.0000.00717.44
8.1.70.0030.00317.37
8.1.60.0000.00817.70
8.1.50.0030.00517.51
8.1.40.0040.00417.56
8.1.30.0000.00817.74
8.1.20.0000.01017.71
8.1.10.0000.00717.58
8.1.00.0040.00417.46
8.0.300.0060.00318.77
8.0.290.0040.00416.88
8.0.280.0000.00718.52
8.0.270.0030.00317.24
8.0.260.0030.00317.25
8.0.250.0000.00816.99
8.0.240.0070.00416.97
8.0.230.0070.00017.01
8.0.220.0040.00416.87
8.0.210.0000.00816.95
8.0.200.0040.00416.99
8.0.190.0070.00017.01
8.0.180.0000.00717.03
8.0.170.0000.00816.92
8.0.160.0000.00817.01
8.0.150.0000.00716.93
8.0.140.0000.00716.93
8.0.130.0060.00013.43
8.0.120.0050.00216.84
8.0.110.0040.00416.99
8.0.100.0040.00416.92
8.0.90.0040.00416.91
8.0.80.0070.01116.88
8.0.70.0000.00717.02
8.0.60.0040.00416.98
8.0.50.0070.00016.84
8.0.30.0090.01017.23
8.0.20.0090.01317.40
8.0.10.0070.00016.88
8.0.00.0130.00716.97
7.4.330.0000.00415.55
7.4.320.0000.00616.56
7.4.300.0000.00716.43
7.4.290.0030.00316.59
7.4.280.0050.00316.71
7.4.270.0070.00416.65
7.4.260.0000.00716.57
7.4.250.0040.00416.50
7.4.240.0040.00416.43
7.4.230.0000.00716.73
7.4.220.0000.00816.77
7.4.210.0060.00916.63
7.4.200.0000.00716.68
7.4.160.0060.01016.51
7.4.140.0110.00917.86
7.4.130.0140.00716.64
7.4.120.0110.00816.57
7.4.110.0130.00316.55
7.4.100.0030.01316.32
7.4.90.0100.00716.42
7.4.80.0130.01019.39
7.4.70.0080.01316.55
7.4.60.0070.01016.56
7.4.50.0070.00716.73
7.4.40.0070.01016.50
7.4.00.0110.00315.13
7.3.330.0000.00513.32
7.3.320.0000.00613.40
7.3.310.0030.00316.48
7.3.300.0030.00516.20
7.3.290.0030.00316.44
7.3.280.0100.00816.32
7.3.260.0100.00716.33
7.3.240.0090.00916.50
7.3.230.0130.01216.31
7.3.210.0030.01316.43
7.3.200.0090.00916.63
7.3.190.0080.00816.59
7.3.180.0060.01016.59
7.3.170.0060.01116.54
7.3.160.0150.00016.53
7.2.330.0120.01416.89
7.2.320.0060.01016.85
7.2.310.0090.01316.71
7.2.300.0070.01016.71
7.2.290.0060.01616.89
7.2.60.0030.01317.06
7.2.40.1890.01518.13
7.2.30.0280.01618.06
7.2.20.2240.01318.28
7.2.10.1630.00917.93
7.2.00.1430.01218.09
7.1.200.0080.00415.68
7.1.160.2260.00717.09
7.1.150.0620.01417.02
7.1.140.0960.01416.60
7.1.130.1490.00917.06
7.1.120.1620.01017.00
7.1.110.1600.01016.36
7.1.100.1860.00916.57
7.1.90.1880.00916.32
7.1.80.1820.00816.46
7.1.70.1810.01015.30
7.1.60.1610.01033.26
7.1.50.1590.01133.06
7.1.40.1890.01532.60
7.1.30.1830.01332.82
7.1.20.2730.01532.60
7.1.10.2060.01014.74
7.1.00.1970.01014.98

preferences:
67.6 ms | 401 KiB | 5 Q