3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Book { private $bookProperties; private $bookMethods; public function __construct(Array $properties = array()) { $this->bookProperties = array(); $this->bookMethods = array(); foreach ($properties as $property => $value) { $this->bookProperties[$property] = $value; } } public function __get($property) { if (!isset($property, $this->bookProperties)) { throw new \Exception('No such property: ' . $property); } else { return $this->bookProperties[$property]; } } public function __set($property, $value) { $this->bookProperties[$property] = $value; } public function addMethod($methodName, $methodCallable) { if (!is_callable($methodCallable)) { throw new InvalidArgumentException('Second parameter must be callable'); } else { $this->bookMethods[$methodName] = $methodCallable; } } public function __call($methodName, Array $args) { if (!isset($methodName, $this->bookMethods)) { throw new \Exception('No such method: ' . $methodName); } else { echo "attempted to create method " . $methodName . " with args: " . var_export($args, true); //return call_user_func_array(array($this, $methodName), $args); } } } $book = new Book; $book->title = 'Code Complete'; print $book->title; $book->addMethod('rateBook', function($rating = 0) { $this->rating = $rating; }); $book->rateBook(5); print $book->rating;

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.0090.00616.88
8.3.50.0170.00521.13
8.3.40.0160.00018.80
8.3.30.0070.00718.57
8.3.20.0080.00820.16
8.3.10.0000.00823.67
8.3.00.0030.00623.51
8.2.180.0070.00718.41
8.2.170.0070.01122.96
8.2.160.0090.00620.39
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00421.12
8.2.120.0040.00426.35
8.2.110.0080.00021.07
8.2.100.0120.00017.93
8.2.90.0040.00419.40
8.2.80.0000.00817.97
8.2.70.0030.00617.75
8.2.60.0060.00318.05
8.2.50.0040.00418.09
8.2.40.0040.00422.19
8.2.30.0040.00419.60
8.2.20.0050.00319.50
8.2.10.0080.00018.02
8.2.00.0000.00718.02
8.1.280.0040.01125.92
8.1.270.0040.00423.92
8.1.260.0040.00428.09
8.1.250.0090.00628.09
8.1.240.0070.00322.54
8.1.230.0090.00319.12
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0060.00317.48
8.1.190.0080.00017.38
8.1.180.0050.00518.10
8.1.170.0040.00418.65
8.1.160.0020.00520.66
8.1.150.0020.00520.83
8.1.140.0060.00319.47
8.1.130.0000.00717.59
8.1.120.0030.00517.51
8.1.110.0020.00517.39
8.1.100.0000.00817.39
8.1.90.0000.00717.37
8.1.80.0000.00817.57
8.1.70.0030.00517.40
8.1.60.0030.00517.64
8.1.50.0030.00617.46
8.1.40.0000.00817.56
8.1.30.0000.00817.57
8.1.20.0060.00617.73
8.1.10.0050.00317.57
8.1.00.0000.00917.53
8.0.300.0000.00718.77
8.0.290.0030.00616.63
8.0.280.0000.00718.45
8.0.270.0020.00517.32
8.0.260.0000.00817.21
8.0.250.0070.00016.89
8.0.240.0000.00716.92
8.0.230.0000.00717.07
8.0.220.0030.00316.96
8.0.210.0000.00816.92
8.0.200.0040.00416.92
8.0.190.0080.00016.97
8.0.180.0050.00216.93
8.0.170.0090.00016.99
8.0.160.0060.00316.98
8.0.150.0080.00016.95
8.0.140.0000.00716.81
8.0.130.0000.00613.38
8.0.120.0050.00316.86
8.0.110.0040.00416.88
8.0.100.0000.00716.87
8.0.90.0000.00716.85
8.0.80.0140.00616.89
8.0.70.0040.00416.76
8.0.60.0040.00416.80
8.0.50.0050.00216.83
8.0.30.0080.01117.17
8.0.20.0150.00717.40
8.0.10.0060.00317.11
8.0.00.0090.01116.98
7.4.330.0020.00216.85
7.4.320.0030.00316.63
7.4.300.0000.00816.57
7.4.290.0000.00716.52
7.4.280.0000.00716.51
7.4.270.0000.00716.49
7.4.260.0000.00816.61
7.4.250.0050.00216.46
7.4.240.0030.00316.50
7.4.230.0040.00416.63
7.4.220.0040.01416.54
7.4.210.0090.00616.63
7.4.200.0000.00816.59
7.4.160.0110.00516.59
7.4.150.0100.00717.40
7.4.140.0130.01017.86
7.4.130.0070.01016.56
7.4.120.0090.00816.57
7.4.110.0130.00616.66
7.4.100.0100.01316.55
7.4.90.0030.01316.46
7.4.80.0120.01219.39
7.4.70.0120.00316.63
7.4.60.0120.01216.53
7.4.50.0030.01016.54
7.4.40.0140.00316.43
7.4.30.0180.00916.58
7.4.00.0080.00815.11
7.3.330.0060.00013.40
7.3.320.0000.00613.41
7.3.310.0000.00716.41
7.3.300.0030.00316.39
7.3.290.0000.00716.38
7.3.280.0130.00516.44
7.3.270.0000.01717.40
7.3.260.0170.00016.61
7.3.250.0070.01116.51
7.3.240.0050.01216.56
7.3.230.0110.00616.39
7.3.210.0030.01316.59
7.3.200.0100.01019.39
7.3.190.0190.00016.29
7.3.180.0160.00316.49
7.3.170.0120.00916.48
7.3.160.0070.01016.59
7.2.330.0140.00316.53
7.2.320.0110.00616.75
7.2.310.0150.00616.55
7.2.300.0130.00316.74
7.2.290.0120.00416.75
7.2.00.0230.00919.30
7.1.100.0100.00317.39
7.1.70.0100.00017.22
7.1.60.0030.02019.40
7.1.50.0000.01016.73
7.1.00.0100.06722.36
7.0.200.0080.00514.64
7.0.60.0170.08021.59
7.0.50.0070.08717.98
7.0.40.0030.05020.23
7.0.30.0300.06320.06
7.0.20.0370.07320.30
7.0.10.0030.04320.23
7.0.00.0030.08320.21
5.6.280.0070.04320.93
5.6.210.0170.08020.48
5.6.200.0070.05318.16
5.6.190.0070.07720.51
5.6.180.0300.06720.41
5.6.170.0130.08720.56
5.6.160.0070.06020.54
5.6.150.0000.04318.15
5.6.140.0030.04318.18
5.6.130.0070.04018.18
5.6.120.0070.07021.05
5.6.110.0100.08021.05
5.6.100.0100.08021.12
5.6.90.0030.08720.98
5.6.80.0070.06020.50
5.5.350.0070.07020.42
5.5.340.0170.06317.94
5.5.330.0030.06320.29
5.5.320.0500.04320.36
5.5.310.0300.07320.51
5.5.300.0000.04318.04
5.5.290.0070.08717.98
5.5.280.0070.04320.79
5.5.270.0030.07720.81
5.5.260.0000.09020.91
5.5.250.0100.07020.68
5.5.240.0100.04020.20

preferences:
37.41 ms | 401 KiB | 5 Q