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), array($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.0570.06480.63
8.3.50.0740.07280.49
8.3.40.0330.04348.34
8.3.30.0270.03348.79
8.3.20.0300.03051.34
8.2.180.0770.07080.34
8.2.170.0370.03748.83
8.2.160.0360.02050.06
8.2.150.0200.03048.98
8.1.280.0630.04979.93
7.4.10.0260.07978.43
7.4.00.0340.08178.45
7.3.130.0500.09678.41
7.3.120.0450.09478.30
7.3.110.0550.09278.41
7.3.100.0320.06578.24
7.3.90.0260.10678.27
7.3.80.0400.07878.43
7.3.70.0380.07078.26
7.3.60.0430.06478.43
7.3.50.0310.10978.38
7.3.40.0280.08878.28
7.3.30.0300.07778.07
7.3.20.0650.06878.91
7.3.10.0820.06278.95
7.3.00.0740.05878.75
7.2.260.0400.14178.47
7.2.250.0450.14178.45
7.2.240.0280.12978.60
7.2.230.0420.10578.64
7.2.220.0500.12278.66
7.2.210.0430.11778.47
7.2.200.0350.12078.73
7.2.190.0380.13178.69
7.2.180.0500.11378.55
7.2.170.0320.12678.56
7.2.160.0270.11478.38
7.2.150.0240.08479.27
7.2.140.0400.09079.29
7.2.130.0540.10079.15
7.2.120.0610.09879.22
7.2.110.0870.09279.04
7.2.100.0990.10278.89
7.2.90.0570.09479.18
7.2.80.0810.09879.30
7.2.70.0740.10079.04
7.2.60.0960.10379.14
7.2.50.0820.09879.18
7.2.40.1020.11279.18
7.2.30.0990.11579.03
7.2.20.0760.11279.20
7.2.10.1130.10378.98
7.2.00.1190.09279.80
7.1.330.0230.10678.06
7.1.320.0170.13178.19
7.1.310.0230.13677.94
7.1.300.0180.11378.14
7.1.290.0450.11278.26
7.1.280.0180.11777.95
7.1.270.0520.12077.89
7.1.260.0710.10978.12
7.1.250.0500.11678.10
7.1.240.0130.11078.14
7.1.230.0390.11578.14
7.1.220.0200.11478.06
7.1.210.0380.08378.27
7.1.200.0850.09878.12
7.1.190.0420.11278.32
7.1.180.0290.12077.87
7.1.170.0340.13778.23
7.1.160.0200.11178.30
7.1.150.0330.11478.07
7.1.140.1810.11877.95
7.1.130.1260.10778.31
7.1.120.1950.13277.99
7.1.110.0240.11178.10
7.1.100.0470.05452.16
7.1.90.0220.10878.04
7.1.80.0300.11878.25
7.1.70.0360.04745.46
7.1.60.0250.12478.84
7.1.50.0270.09778.56
7.1.40.0400.11478.08
7.1.30.0300.11678.11
7.1.20.0150.0059.48
7.1.10.0430.10678.25
7.1.00.0320.12881.34
7.0.330.0200.09477.57
7.0.320.0230.09977.79
7.0.310.0300.12077.75
7.0.300.0240.10577.75
7.0.290.0130.12177.54
7.0.280.0140.11277.45
7.0.270.0260.11377.79
7.0.260.0160.10877.86
7.0.250.0170.10177.98
7.0.240.0820.08977.70
7.0.230.0630.10277.80
7.0.220.0330.10877.67
7.0.210.0490.09377.78
7.0.200.3490.10578.05
7.0.190.0360.10477.79
7.0.180.0430.09877.85
7.0.170.0280.10777.91
7.0.160.0430.09577.49
7.0.150.0200.10577.78
7.0.140.0160.00511.08
7.0.130.0390.09477.76
7.0.120.0180.11373.63
7.0.110.0130.11677.88
7.0.100.0320.09577.73
7.0.90.0290.11277.87
7.0.80.0540.09977.82
7.0.70.0270.12477.83
7.0.60.0890.12680.75
7.0.50.0310.11679.84
7.0.40.0290.13817.06
7.0.30.0250.14016.97
7.0.20.0300.11217.02
7.0.10.0190.10417.11
7.0.00.0320.13116.96
5.6.400.0130.02133.37
5.6.390.0250.01233.62
5.6.380.0220.01133.29
5.6.370.0200.02033.24
5.6.360.0150.02633.35
5.6.350.0200.01833.41
5.6.340.0170.02433.27
5.6.330.0200.01733.34
5.6.320.0240.02133.18
5.6.310.0360.02033.26
5.6.300.0240.02433.46
5.6.290.0270.02433.23
5.6.280.0100.04836.58
5.6.270.0250.02433.23
5.6.260.0270.01733.43
5.6.250.0390.01033.24
5.6.240.0280.01633.17
5.6.230.0250.02233.32
5.6.220.0190.02333.37
5.6.210.0180.05536.43
5.6.200.0260.04935.10
5.6.190.0150.06236.40
5.6.180.0270.04936.17
5.6.170.0280.05436.30
5.6.160.0290.05136.40
5.6.150.0180.05335.07
5.6.140.0210.04935.10
5.6.130.0190.03535.02
5.6.120.0200.03936.72
5.6.110.0280.03536.56
5.6.100.0170.04736.54
5.6.90.0250.03036.69
5.6.80.0200.03336.14
5.6.70.0270.02033.25
5.6.60.0220.02233.04
5.6.50.0310.01733.36
5.6.40.0250.02233.25
5.6.30.0200.02033.30
5.6.20.0160.02433.18
5.6.10.0280.02133.14
5.6.00.0120.0039.07
5.5.380.0240.01833.68
5.5.370.0340.01033.50
5.5.360.0160.02333.48
5.5.350.0190.05536.50
5.5.340.0190.05135.30
5.5.330.0180.05836.38
5.5.320.0330.03036.44
5.5.310.0400.03936.21
5.5.300.0160.03435.28
5.5.290.0200.04635.34
5.5.280.0180.04236.68
5.5.270.0150.04836.69
5.5.260.0230.04436.73
5.5.250.0210.05436.44
5.5.240.0240.03036.30
5.5.230.0270.01833.34
5.5.220.0210.01833.21
5.5.210.0210.02533.37
5.5.200.0200.02333.47
5.5.190.0310.01433.19
5.5.180.0200.02533.68
5.5.170.0350.01533.63
5.5.160.0300.01533.58
5.5.150.0190.02533.54
5.5.140.0220.02233.83
5.5.130.0190.02633.21
5.5.120.0280.01933.61
5.5.110.0290.01833.70
5.5.100.0250.01833.52
5.5.90.0190.02633.17
5.5.80.0230.01333.33
5.5.70.0240.01633.59
5.5.60.0220.02233.47
5.5.50.0200.01733.48
5.5.40.0140.02733.23
5.5.30.0200.02033.49
5.5.20.0190.02633.32
5.5.10.0350.00733.61
5.5.00.0160.02033.01

preferences:
36.75 ms | 401 KiB | 5 Q