3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ShopProduct { public $discount = 0; public $title; public $producerMainName; public $producerFirstName; protected $price; function __construct($title, $firstName, $mainName, $price) { $this->title = $title; $this->producerFirstName = $firstName; $this->producerMainName = $mainName; $this->price = $price; } function getSummaryLine(){ $base = "{$this->title} ( {$this->producerMainName}, "; $base .= "{$this->producerFirstName} )"; return $base; } function getProducer() { return "{$this->producerFirstName} " . "{$this->producerMainName}"; } function setDiscount(){ $this->discount=$num; } public function getPrice() { # code... return ($this->price - $this->discount); } } class ShopProductWriter{ private $products = array(); public function addProduct( ShopProduct $shopProduct){ $this->product[] = $shopProduct; } public function write(){ $str = ""; foreach ($this->products as $shopProduct) { $str .= "{$shopProduct->title}: "; $str .= "{$shopProduct->getProducer()}"; $str .= "{$shopProduct->getPrice()}\n"; } print $str; } } class CDProduct extends ShopProduct { public $playLength; function __construct($title, $firstName, $mainName, $price, $playLength){ parent::__construct($title, $firstName, $mainName, $price); $this->playLength = $playLength; } function getPlayLength(){ return $this->playLength; } function getSummaryLine(){ $base = parent::getSummaryLine(); $base .= " :Legth of song {$this->playLength}"; return $base; } } class BookProduct extends shopProduct{ public $numPages; function __construct($title, $firstName, $mainName, $price, $numPages){ parent::__construct($title, $firstName, $mainName, $price); $this->playLength = $playLength; } function getSummaryLine(){ $base = parent::getSummaryLine(); $base .= ": Number of pages - {$this->numPages}"; } function getProducer() { return "{$this->producerFirstName} " . "{$this->producerMainName}"; } function getPrice(){ return $this->price; } } $product2 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53); $product3 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53); $product4 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53); $product5 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53); print write();

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.00716.63
8.3.50.0140.00521.09
8.3.40.0040.01118.97
8.3.30.0160.00318.83
8.3.20.0040.00420.03
8.3.10.0040.00421.69
8.3.00.0030.00523.33
8.2.180.0110.00418.29
8.2.170.0040.01122.96
8.2.160.0070.01020.39
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0000.00920.90
8.2.120.0070.00026.35
8.2.110.0040.00419.21
8.2.100.0030.00917.91
8.2.90.0040.00419.04
8.2.80.0090.00017.97
8.2.70.0060.00317.50
8.2.60.0050.00517.93
8.2.50.0060.00318.09
8.2.40.0050.00322.05
8.2.30.0000.00719.35
8.2.20.0000.00917.75
8.2.10.0040.00418.11
8.2.00.0000.00718.04
8.1.280.0140.00325.92
8.1.270.0090.00922.19
8.1.260.0040.00428.09
8.1.250.0000.00828.09
8.1.240.0030.00622.42
8.1.230.0120.00017.77
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0090.00017.38
8.1.190.0030.00517.36
8.1.180.0030.00618.10
8.1.170.0080.00018.63
8.1.160.0070.00020.66
8.1.150.0000.01018.84
8.1.140.0000.00819.49
8.1.130.0030.00317.68
8.1.120.0040.00417.31
8.1.110.0000.00817.43
8.1.100.0040.00417.48
8.1.90.0040.00417.41
8.1.80.0000.00717.36
8.1.70.0000.00717.48
8.1.60.0040.00417.67
8.1.50.0030.00617.50
8.1.40.0000.00917.63
8.1.30.0030.00517.64
8.1.20.0040.00417.73
8.1.10.0020.00517.60
8.1.00.0000.00717.61
8.0.300.0080.00018.77
8.0.290.0040.00416.75
8.0.280.0030.00318.46
8.0.270.0030.00317.27
8.0.260.0030.00317.24
8.0.250.0000.00816.91
8.0.240.0000.00717.05
8.0.230.0080.00017.05
8.0.220.0050.00216.95
8.0.210.0000.00816.96
8.0.200.0030.00316.96
8.0.190.0050.00216.90
8.0.180.0000.00716.87
8.0.170.0080.00016.95
8.0.160.0030.00416.95
8.0.150.0040.00416.80
8.0.140.0080.00016.80
8.0.130.0000.00513.39
8.0.120.0000.00816.89
8.0.110.0050.00316.91
8.0.100.0050.00216.79
8.0.90.0050.00316.91
8.0.80.0080.00816.91
8.0.70.0000.00816.86
8.0.60.0050.00216.86
8.0.50.0030.00616.90
8.0.30.0120.00917.03
8.0.20.0180.00517.42
8.0.10.0040.00416.98
8.0.00.0110.00616.70
7.4.330.0020.00216.74
7.4.320.0080.00016.64
7.4.300.0050.00316.65
7.4.290.0040.00416.47
7.4.280.0000.00816.66
7.4.270.0070.00016.63
7.4.260.0040.00416.64
7.4.250.0040.00416.46
7.4.240.0030.00616.62
7.4.230.0040.00416.46
7.4.220.0070.01016.55
7.4.210.0040.01216.70
7.4.200.0030.00516.72
7.4.160.0090.00616.49
7.4.150.0110.00717.40
7.4.140.0120.01217.86
7.4.130.0140.00516.45
7.4.120.0110.00816.50
7.4.110.0030.01416.57
7.4.100.0140.00316.63
7.4.90.0090.00916.49
7.4.80.0070.01119.39
7.4.70.0070.01016.66
7.4.60.0130.00316.72
7.4.50.0000.01416.59
7.4.40.0150.00316.55
7.4.30.0120.01216.61
7.4.00.0070.01114.91
7.3.330.0000.00613.38
7.3.320.0050.00013.25
7.3.310.0000.00716.32
7.3.300.0030.00316.36
7.3.290.0070.00016.46
7.3.280.0080.01016.39
7.3.270.0150.00317.40
7.3.260.0040.01516.32
7.3.250.0090.01216.47
7.3.240.0060.01116.46
7.3.230.0030.01316.43
7.3.210.0070.01016.40
7.3.200.0040.01319.39
7.3.190.0060.01016.42
7.3.180.0100.00716.28
7.3.170.0140.00316.41
7.3.160.0150.00016.47
7.3.10.0050.00516.45
7.3.00.0040.01116.59
7.2.330.0120.00616.61
7.2.320.0060.01216.44
7.2.310.0070.01016.68
7.2.300.0070.01016.41
7.2.290.0090.00816.62
7.2.130.0030.01316.45
7.2.120.0130.00316.67
7.2.110.0000.01116.56
7.2.100.0040.01216.81
7.2.90.0080.00316.84
7.2.80.0040.00816.87
7.2.70.0100.00316.99
7.2.60.0060.00816.66
7.2.50.0070.00716.98
7.2.40.0100.01317.04
7.2.30.0110.00416.82
7.2.20.0110.00516.77
7.2.10.0000.01916.71
7.2.00.0050.00918.04
7.1.250.0060.00915.70
7.1.240.0090.00315.64
7.1.230.0080.00415.73
7.1.220.0070.00715.52
7.1.210.0000.01315.75
7.1.200.0040.01015.65
7.1.190.0000.01415.58
7.1.180.0030.00815.67
7.1.170.0040.00815.70
7.1.160.0110.00615.79
7.1.150.0120.00315.57
7.1.140.0130.00015.52
7.1.130.0110.00415.52
7.1.120.0110.00315.64
7.1.110.0110.00715.69
7.1.100.0060.00616.84
7.1.90.0060.00615.54
7.1.80.0050.00215.62
7.1.70.0040.00916.39
7.1.60.0090.01117.49
7.1.50.0080.00816.36
7.1.40.0110.00015.64
7.1.30.0070.00715.61
7.1.20.0090.00015.56
7.1.10.0090.00315.61
7.1.00.0100.03519.07
7.0.330.0120.00315.38
7.0.320.0060.00615.43
7.0.310.0070.00715.03
7.0.300.0050.01415.34
7.0.290.0080.01115.36
7.0.280.0060.01115.14
7.0.270.0110.00715.21
7.0.260.0060.00615.43
7.0.250.0000.01315.31
7.0.240.0060.01015.05
7.0.230.0050.00815.24
7.0.220.0040.00815.21
7.0.210.0070.00415.41
7.0.200.0040.00716.01
7.0.190.0030.00615.36
7.0.180.0070.00415.41
7.0.170.0030.00815.39
7.0.160.0100.00715.36
7.0.150.0100.00715.57
7.0.140.0030.00715.49
7.0.130.0060.00615.54
7.0.120.0080.01115.36
7.0.110.0070.01015.32
7.0.100.0000.00914.92
7.0.90.0060.00615.46
7.0.80.0030.01215.41
7.0.70.0060.00615.05
7.0.60.0070.02218.69
7.0.50.0100.03516.68
7.0.40.0070.04016.84
7.0.30.0180.02516.80
7.0.20.0200.04216.74
7.0.10.0040.03116.83
7.0.00.0120.02316.83
5.6.380.0060.01013.96
5.6.370.0100.00214.60
5.6.360.0060.00914.13
5.6.350.0040.01414.38
5.6.340.0030.01014.44
5.6.330.0060.00314.19
5.6.320.0110.00014.15
5.6.310.0130.00014.39
5.6.300.0090.00314.16
5.6.290.0000.01414.10
5.6.280.0040.01817.72
5.6.270.0100.00714.55
5.6.260.0040.01114.63
5.6.250.0030.01414.45
5.6.240.0040.00414.11
5.6.230.0130.00314.40
5.6.220.0070.00314.45
5.6.210.0050.03017.50
5.6.200.0020.03016.40
5.6.190.0100.04317.42
5.6.180.0200.03717.41
5.6.170.0240.04517.51
5.6.160.0020.05317.31
5.6.150.0030.04616.24
5.6.140.0040.04116.20
5.6.130.0040.04816.25
5.6.120.0090.02617.60
5.6.110.0100.03817.63
5.6.100.0070.03317.85
5.6.90.0090.04417.74
5.6.80.0070.03617.24
5.6.70.0000.01214.05
5.6.60.0000.01314.11
5.6.50.0040.01114.14
5.6.40.0040.01014.36
5.6.30.0080.00414.13
5.6.20.0060.00614.39
5.6.10.0080.00814.05
5.6.00.0090.00614.06
5.5.380.0000.00811.11
5.5.370.0040.00411.06
5.5.360.0000.00911.11
5.5.350.0200.03615.80
5.5.340.0040.03814.44
5.5.330.0050.04515.69
5.5.320.0160.02115.63
5.5.310.0190.04215.70
5.5.300.0060.04114.44
5.5.290.0060.04314.42
5.5.280.0160.03715.97
5.5.270.0020.04016.14
5.5.260.0100.03715.95
5.5.250.0090.03215.79
5.5.240.0130.03515.28
5.5.230.0040.00711.04
5.5.220.0070.00011.04
5.5.210.0070.00310.86
5.5.200.0030.00811.00
5.5.190.0080.00010.95
5.5.180.0030.00711.10
5.5.170.0040.00410.96
5.5.160.0070.00010.75
5.5.150.0030.00610.83
5.5.140.0060.00610.83
5.5.130.0030.00710.92
5.5.120.0030.00910.84
5.5.110.0120.00311.14
5.5.100.0130.00011.04
5.5.90.0030.01011.12
5.5.80.0060.00610.90
5.5.70.0040.00810.88
5.5.60.0030.00911.22
5.5.50.0030.00911.05
5.5.40.0030.00711.16
5.5.30.0040.00911.18
5.5.20.0070.00311.10
5.5.10.0080.00010.93
5.5.00.0000.00810.95

preferences:
61.73 ms | 401 KiB | 5 Q