3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Server { private $hostname; private $cpu; private $ram; public function __construct($hostname, $cpu, $ram) { $this->hostname = $hostname; $this->cpu = $cpu; $this->ram = $ram; } public function getHostname() { return $this->hostname; } public function setHostname($hostname) { return $this->hostname = ($hostname == null ? $this->_exception("Hostname must not be null.") : $hostname); } public function getCpu() { return $this->cpu; } public function setCpu($cpu) { return $this->cpu = ($cpu == null ? $this->_exception("CPU must not be null.") : $cpu); } public function getRam() { return $this->ram; } public function setRam($ram) { return $this->ram = ($ram == null ? $this->_exception("RAM must not be null.") : $ram); } public function getRamInGb() { return $this->ram / 1024; } public function addRam($ram) { return $this->ram = ($ram === null ? $this->_exception("RAM must not be null.") : $this->ram + $ram); } public function subRam($ram) { return $this->ram = ($this->ram - $ram < 0 ? $this->_exception("RAM must not result in a below-zero value.") : $this->ram - $ram); } protected function _exception($text = null) { throw new InvalidArgumentException($text); } } $server = new Server("test.com", "Intel Xeon E5-2680 v2 2.8Ghz", 1024); echo $server->getHostname(); // "test.com" echo $server->setHostname("test.com"); // "test.com" echo $server->getCpu(); // "Intel Xeon E5-2680 v2 2.8Ghz" echo $server->setCpu("Intel Xeon E5-2680 v3 2.8Ghz"); // "Intel Xeon E5-2680 v3 2.8Ghz" echo $server->getRam(); // 1024 echo $server->getRamInGb(); // 1 echo $server->addRam(1024); // 2048 echo $server->getRamInGb(); // 2 echo $server->subRam(1024); // 1024 echo $server->getRamInGb(); // 1 echo $server->subRam(1024); // 0 echo $server->getRamInGb(); // 0 echo $server->subRam(1024); // InvalidArgumentException echo $server->getRamInGb(); // 0 echo $server->setRam(1024); // 1024 echo $server->getRamInGb(); // 1 echo $server->setRam(-1024); // InvalidArgumentException echo $server->getRamInGb(); // 1

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.0140.00417.13
8.3.50.0110.00822.16
8.3.40.0150.00018.75
8.3.30.0040.01118.92
8.3.20.0040.00420.16
8.3.10.0030.00523.65
8.3.00.0060.00319.77
8.2.180.0060.00918.29
8.2.170.0130.00622.96
8.2.160.0030.01020.43
8.2.150.0070.00024.18
8.2.140.0030.00524.66
8.2.130.0080.00019.38
8.2.120.0090.00026.35
8.2.110.0070.00321.18
8.2.100.0090.00318.04
8.2.90.0060.00319.07
8.2.80.0000.00817.97
8.2.70.0100.00017.61
8.2.60.0040.00417.80
8.2.50.0040.00418.07
8.2.40.0050.00321.95
8.2.30.0040.00420.68
8.2.20.0040.00417.88
8.2.10.0070.00018.16
8.2.00.0000.00818.02
8.1.280.0040.01125.92
8.1.270.0110.00720.36
8.1.260.0080.00028.09
8.1.250.0030.00528.09
8.1.240.0080.00319.27
8.1.230.0080.00417.56
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0000.00917.35
8.1.190.0030.00517.35
8.1.180.0040.00418.10
8.1.170.0030.00518.45
8.1.160.0000.00720.81
8.1.150.0050.00218.95
8.1.140.0040.00419.62
8.1.130.0070.00017.68
8.1.120.0070.00017.54
8.1.110.0050.00217.55
8.1.100.0040.00417.58
8.1.90.0050.00317.42
8.1.80.0000.00717.47
8.1.70.0040.00417.43
8.1.60.0060.00317.57
8.1.50.0030.00617.59
8.1.40.0040.00417.55
8.1.30.0060.00317.75
8.1.20.0030.00617.67
8.1.10.0000.00817.67
8.1.00.0040.00417.61
8.0.300.0000.00818.77
8.0.290.0080.00017.00
8.0.280.0000.00718.43
8.0.270.0070.00017.36
8.0.260.0030.00317.37
8.0.250.0000.00816.98
8.0.240.0000.00717.09
8.0.230.0000.00716.98
8.0.220.0000.00717.02
8.0.210.0000.00717.00
8.0.200.0060.00016.98
8.0.190.0060.00317.04
8.0.180.0000.00816.87
8.0.170.0080.00017.03
8.0.160.0020.00517.04
8.0.150.0040.00416.93
8.0.140.0050.00216.99
8.0.130.0060.00013.43
8.0.120.0040.00416.88
8.0.110.0040.00417.02
8.0.100.0080.00016.88
8.0.90.0040.00416.92
8.0.80.0060.01617.07
8.0.70.0040.00416.92
8.0.60.0050.00316.93
8.0.50.0030.00517.07
8.0.30.0080.01017.10
8.0.20.0120.00717.41
8.0.10.0000.00717.00
8.0.00.0100.00816.86
7.4.330.0020.00216.67
7.4.320.0030.00316.68
7.4.300.0030.00316.68
7.4.290.0000.00816.63
7.4.280.0060.00316.52
7.4.270.0070.00016.66
7.4.260.0040.00716.65
7.4.250.0070.00016.61
7.4.240.0040.00416.49
7.4.230.0020.00516.55
7.4.220.0060.01916.48
7.4.210.0030.01016.66
7.4.200.0040.00416.66
7.4.160.0090.00616.62
7.4.150.0110.00717.40
7.4.140.0100.00817.86
7.4.130.0130.00816.60
7.4.120.0130.00616.63
7.4.110.0150.00316.59
7.4.100.0150.00416.54
7.4.90.0070.01016.63
7.4.80.0140.00719.39
7.4.70.0090.00916.46
7.4.60.0090.01416.49
7.4.50.0060.00916.52
7.4.40.0100.00616.71
7.4.30.0030.01416.52
7.4.00.0040.01115.18
7.3.330.0070.00013.34
7.3.320.0050.00013.40
7.3.310.0030.00316.33
7.3.300.0070.00016.43
7.3.290.0070.00816.52
7.3.280.0140.00716.44
7.3.270.0040.01617.40
7.3.260.0130.00416.54
7.3.250.0110.00916.54
7.3.240.0130.00616.50
7.3.230.0120.00816.57
7.3.210.0110.00616.63
7.3.200.0060.00916.55
7.3.190.0170.00016.44
7.3.180.0100.00616.60
7.3.170.0170.00516.58
7.3.160.0130.00616.79
7.2.330.0140.00916.68
7.2.320.0030.01516.73
7.2.310.0090.00816.61
7.2.300.0090.00716.49
7.2.290.0070.01016.71
7.2.60.0070.00716.89
7.2.00.0140.00718.73
7.1.200.0000.01415.55
7.1.100.0030.00818.36
7.1.70.0040.00417.29
7.1.60.0080.01519.13
7.1.50.0110.01117.03
7.1.00.0070.07322.36
7.0.200.0750.00314.57
7.0.60.0130.07719.91
7.0.50.0300.04317.91
7.0.40.0070.04320.27
7.0.30.0130.05320.09
7.0.20.0270.04020.16
7.0.10.0100.08320.12
7.0.00.0130.08720.34
5.6.280.0030.07021.13
5.6.210.0000.04320.67
5.6.200.0000.08318.28
5.6.190.0170.07720.48
5.6.180.0130.07720.59
5.6.170.0230.07020.47
5.6.160.0070.06020.56
5.6.150.0070.08318.17
5.6.140.0130.07718.27
5.6.130.0000.09018.18
5.6.120.0170.07320.92
5.6.110.0000.04321.06
5.6.100.0130.06021.11
5.6.90.0170.06721.13
5.6.80.0100.07020.45
5.5.350.0170.07720.46
5.5.340.0030.04018.08
5.5.330.0000.05020.33
5.5.320.0370.05020.36
5.5.310.0300.07320.23
5.5.300.0070.08017.98
5.5.290.0170.07017.99
5.5.280.0100.08020.90
5.5.270.0170.05320.82
5.5.260.0170.07320.87
5.5.250.0030.09020.53
5.5.240.0130.03020.21

preferences:
56.13 ms | 401 KiB | 5 Q