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 ShopProductWriter::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.0060.00917.00
8.3.50.0070.00716.47
8.3.40.0070.00718.66
8.3.30.0070.00718.90
8.3.20.0070.00020.22
8.3.10.0040.00421.73
8.3.00.0080.00023.61
8.2.180.0170.00318.41
8.2.170.0070.01422.96
8.2.160.0000.01720.53
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00420.95
8.2.120.0080.00026.35
8.2.110.0140.00719.17
8.2.100.0060.00617.92
8.2.90.0030.00519.28
8.2.80.0080.00017.97
8.2.70.0030.00617.75
8.2.60.0030.00617.93
8.2.50.0040.00418.09
8.2.40.0030.00622.09
8.2.30.0000.00719.38
8.2.20.0070.00317.63
8.2.10.0020.00517.96
8.2.00.0040.00417.95
8.1.280.0100.00725.92
8.1.270.0150.00722.00
8.1.260.0000.00828.09
8.1.250.0080.00028.09
8.1.240.0070.01022.38
8.1.230.0080.00317.82
8.1.220.0080.00017.77
8.1.210.0040.00418.77
8.1.200.0030.00717.47
8.1.190.0030.00617.36
8.1.180.0040.00418.10
8.1.170.0000.00918.63
8.1.160.0080.00020.64
8.1.150.0060.00320.68
8.1.140.0040.00419.52
8.1.130.0070.00017.72
8.1.120.0040.00417.54
8.1.110.0000.00817.46
8.1.100.0040.00417.47
8.1.90.0000.00817.46
8.1.80.0000.00717.45
8.1.70.0030.00317.45
8.1.60.0040.00417.54
8.1.50.0060.00317.46
8.1.40.0000.00817.55
8.1.30.0040.00417.77
8.1.20.0050.00317.63
8.1.10.0040.00417.65
8.1.00.0000.00817.43
8.0.300.0000.00718.77
8.0.290.0040.00416.63
8.0.280.0040.00418.40
8.0.270.0030.00317.27
8.0.260.0050.00317.20
8.0.250.0000.00717.02
8.0.240.0030.00316.92
8.0.230.0000.00716.99
8.0.220.0040.00417.01
8.0.210.0030.00316.93
8.0.200.0000.00717.03
8.0.190.0050.00317.01
8.0.180.0040.00416.95
8.0.170.0050.00316.88
8.0.160.0030.00317.07
8.0.150.0030.00416.92
8.0.140.0000.00716.94
8.0.130.0030.00313.48
8.0.120.0040.00416.82
8.0.110.0050.00316.89
8.0.100.0000.00716.89
8.0.90.0040.00417.01
8.0.80.0060.00916.85
8.0.70.0050.00317.00
8.0.60.0040.00416.83
8.0.50.0000.00716.79
8.0.30.0080.01117.29
8.0.20.0120.00817.40
8.0.10.0000.00717.07
8.0.00.0090.01116.73
7.4.330.0000.00616.83
7.4.320.0000.00716.44
7.4.300.0040.00416.69
7.4.290.0030.00616.71
7.4.280.0070.00016.62
7.4.270.0030.00316.59
7.4.260.0060.00316.46
7.4.250.0080.00016.55
7.4.240.0070.00016.63
7.4.230.0030.00316.60
7.4.220.0140.00416.61
7.4.210.0050.00916.68
7.4.200.0030.00516.77
7.4.160.0120.00316.50
7.4.150.0150.00417.40
7.4.140.0080.01317.86
7.4.130.0050.01516.62
7.4.120.0110.00716.62
7.4.110.0030.01416.78
7.4.100.0070.01116.61
7.4.90.0120.00916.44
7.4.80.0120.00619.39
7.4.70.0060.01616.61
7.4.60.0100.00616.67
7.4.50.0110.00416.52
7.4.40.0090.00916.64
7.4.30.0070.01016.52
7.4.00.0030.01315.07
7.3.330.0000.00613.41
7.3.320.0000.00613.48
7.3.310.0000.00716.34
7.3.300.0030.00316.34
7.3.290.0000.00716.28
7.3.280.0090.00816.38
7.3.270.0030.01417.40
7.3.260.0170.00716.48
7.3.250.0070.01016.38
7.3.240.0050.01316.54
7.3.230.0160.00016.60
7.3.210.0100.00616.41
7.3.200.0110.00919.39
7.3.190.0100.00716.46
7.3.180.0060.01216.41
7.3.170.0060.01116.65
7.3.160.0030.01316.43
7.2.330.0110.00716.42
7.2.320.0100.00616.74
7.2.310.0120.00616.69
7.2.300.0030.01716.77
7.2.290.0060.01216.75
7.2.60.0070.00716.94
7.2.00.0060.00619.55
7.1.200.0070.00715.73
7.1.100.0040.00418.09
7.1.70.0060.00317.07
7.1.60.0040.02219.40
7.1.50.0070.01316.76
7.1.00.0000.08022.40
7.0.200.0000.00716.73
7.0.60.0300.06720.00
7.0.50.0070.03717.93
7.0.40.0070.07020.13
7.0.30.0300.08320.26
7.0.20.0230.07320.23
7.0.10.0030.04720.20
7.0.00.0070.06320.14
5.6.210.0070.08720.54
5.6.200.0100.05318.27
5.6.190.0130.07720.79
5.6.180.0230.05020.58
5.6.170.0230.04320.54
5.6.160.0100.07720.54
5.6.150.0100.08018.16
5.6.140.0100.07718.25
5.6.130.0070.06018.20
5.6.120.0070.05721.02
5.6.110.0070.06321.14
5.6.100.0100.07021.01
5.6.90.0270.05721.04
5.6.80.0030.04020.38
5.5.350.3900.04020.48
5.5.340.0070.04017.98
5.5.330.0100.07320.38
5.5.320.0270.03720.42
5.5.310.0270.06020.19
5.5.300.0000.07717.97
5.5.290.0030.04017.99
5.5.280.0070.07020.93
5.5.270.0070.03720.89
5.5.260.0100.07720.79
5.5.250.0000.08720.72
5.5.240.0170.08020.29

preferences:
41.75 ms | 400 KiB | 5 Q