3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $secret = 'Nyy lbhe Onfr ner orybat gb hf.'; private $callback; final public function run() { call_user_func($this->callback); return $this->secret . PHP_EOL; } public function __set($k, $v) { print_r($v);exit; $key = $v[($v[$v])]; // $v is some kind of weird array $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test(); // start class MyClass implements arrayaccess{ public $closure; private $container; public function __construct($test){ $this->closure = function(){ echo 'nearly there! just need to reshuffle the letters now, can set secret too as its not in scope.'; }; $this->closure->bindTo($test); $this->container = array('1' => '2', '2' => 'callback'); } public function __toString(){ // Object of class V could not be converted to string; return '1'; } // array access stuff below was copied and pasted from http://www.php.net/manual/en/class.arrayaccess.php public function offsetSet($offset, $value) { if (is_null($offset)) { $this->array[] = $value; } else { $this->array[$offset] = $value; } } public function offsetExists($offset) { return isset($this->array[$offset]); } public function offsetUnset($offset) { unset($this->array[$offset]); } public function offsetGet($offset) { $offset = (string) $offset; return isset($this->array[$offset]) ? $this->array[$offset] : null; } } $test->callback = new MyClass($test); // end editing here echo $test->run();

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.0130.00718.46
8.3.50.0130.00321.89
8.3.40.0000.01418.67
8.3.30.0110.00719.01
8.3.20.0070.00020.34
8.3.10.0050.00321.70
8.3.00.0040.00422.40
8.2.180.0110.01117.00
8.2.170.0070.00722.96
8.2.160.0090.00620.28
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0060.00319.48
8.2.110.0040.00422.27
8.2.100.0120.00019.47
8.2.90.0030.00619.23
8.2.80.0060.00617.97
8.2.70.0040.00417.61
8.2.60.0030.00517.80
8.2.50.0040.00418.07
8.2.40.0040.00418.14
8.2.30.0070.00318.09
8.2.20.0030.00617.81
8.2.10.0060.00319.52
8.2.00.0070.00017.69
8.1.280.0100.00325.92
8.1.270.0080.00022.22
8.1.260.0150.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00423.97
8.1.230.0110.00019.21
8.1.220.0060.00317.76
8.1.210.0080.00018.77
8.1.200.0030.00617.47
8.1.190.0040.00417.55
8.1.180.0040.00418.10
8.1.170.0000.00818.39
8.1.160.0000.00722.14
8.1.150.0000.00818.62
8.1.140.0030.00517.41
8.1.130.0040.00417.86
8.1.120.0000.00817.55
8.1.110.0040.00417.39
8.1.100.0070.00017.45
8.1.90.0040.00717.45
8.1.80.0000.00717.48
8.1.70.0030.00517.49
8.1.60.0060.00317.59
8.1.50.0080.00017.44
8.1.40.0080.00017.56
8.1.30.0040.00417.60
8.1.20.0030.00517.60
8.1.10.0040.00417.62
8.1.00.0030.00717.48
8.0.300.0050.00318.77
8.0.290.0040.00417.05
8.0.280.0000.00718.48
8.0.270.0030.00317.23
8.0.260.0000.00716.85
8.0.250.0070.00017.01
8.0.240.0000.00917.08
8.0.230.0000.00717.00
8.0.220.0080.00017.07
8.0.210.0040.00417.03
8.0.200.0000.00717.09
8.0.190.0050.00317.06
8.0.180.0000.00716.97
8.0.170.0040.00416.89
8.0.160.0040.00416.92
8.0.150.0040.00416.94
8.0.140.0030.00616.91
8.0.130.0060.00013.32
8.0.120.0000.00816.96
8.0.110.0000.00817.04
8.0.100.0030.00316.98
8.0.90.0000.00816.81
8.0.80.0100.01017.05
8.0.70.0000.00717.01
8.0.60.0000.00817.04
8.0.50.0000.00716.99
8.0.30.0120.01417.17
8.0.20.0100.00917.40
8.0.10.0040.00417.05
8.0.00.0110.01117.00
7.4.330.0000.00715.00
7.4.320.0060.00016.43
7.4.300.0000.00716.52
7.4.290.0030.00316.53
7.4.280.0000.00716.60
7.4.270.0000.00716.54
7.4.260.0070.00016.42
7.4.250.0040.00416.62
7.4.240.0060.00116.61
7.4.230.0070.00016.59
7.4.220.0100.00716.70
7.4.210.0130.00416.57
7.4.200.0070.00016.45
7.4.190.0040.00416.50
7.4.160.0060.01016.58
7.4.150.0050.01617.40
7.4.140.0050.01317.86
7.4.130.0050.01316.47
7.4.120.0090.00816.52
7.4.110.0090.00916.54
7.4.100.0140.00716.50
7.4.90.0080.00916.57
7.4.80.0120.00919.39
7.4.70.0130.00516.46
7.4.60.0100.00716.50
7.4.50.0050.00316.44
7.4.40.0040.01122.77
7.4.30.0030.01316.60
7.4.00.0070.01215.02
7.3.330.0020.00213.39
7.3.320.0000.00513.34
7.3.310.0000.00816.48
7.3.300.0000.00616.40
7.3.290.0040.01316.37
7.3.280.0080.00816.35
7.3.270.0060.01117.40
7.3.260.0080.01616.59
7.3.250.0080.00916.41
7.3.240.0090.01316.36
7.3.230.0080.01216.39
7.3.210.0080.01116.57
7.3.200.0090.00619.39
7.3.190.0180.00416.73
7.3.180.0090.00616.61
7.3.170.0110.00416.41
7.3.160.0090.00716.35
7.3.120.0050.01214.90
7.3.110.0140.00414.91
7.3.100.0060.01014.86
7.3.90.0030.00914.63
7.3.80.0070.00714.96
7.3.70.0030.01114.92
7.3.60.0130.00014.77
7.3.50.0070.01014.91
7.3.40.0030.01014.86
7.3.30.0100.00314.80
7.3.20.0110.00316.51
7.3.10.0060.00616.46
7.3.00.0060.00916.77
7.2.330.0030.01416.45
7.2.320.0030.01716.71
7.2.310.0060.01016.77
7.2.300.0100.01016.74
7.2.290.0130.01016.49
7.2.250.0080.01215.18
7.2.240.0100.01015.21
7.2.230.0040.01415.23
7.2.220.0170.00315.25
7.2.210.0000.01515.04
7.2.200.0070.00715.30
7.2.190.0060.00315.22
7.2.180.0120.00315.20
7.2.170.0060.00615.17
7.2.60.0030.01016.63
7.2.00.0030.00619.05
7.1.330.0080.00415.40
7.1.320.0060.00315.60
7.1.310.0000.01415.78
7.1.300.0070.00315.59
7.1.290.0100.00315.90
7.1.280.0060.00615.48
7.1.270.0100.00315.60
7.1.260.0060.00315.79
7.1.200.0030.01015.71
7.1.100.0030.00918.25
7.1.70.0070.00317.03
7.1.60.0000.01219.82
7.1.50.0070.01416.93
7.1.00.0000.08022.54
7.0.200.0000.01016.57
7.0.140.0030.07022.21
7.0.60.0070.05319.88
7.0.50.0100.07317.73
7.0.40.0130.08320.05
7.0.30.0130.04720.20
7.0.20.0330.07720.10
7.0.10.0070.06020.20
7.0.00.0030.06320.33
5.6.280.0000.07721.01
5.6.210.0070.08020.72
5.6.200.0030.04018.16
5.6.190.0170.07720.61
5.6.180.0500.06720.47
5.6.170.0270.05020.50
5.6.160.0170.08020.46
5.6.150.0130.07718.29
5.6.140.0070.05318.19
5.6.130.0030.08018.19
5.6.120.0070.08321.15
5.6.110.0170.07321.01
5.6.100.0070.03721.04
5.6.90.0000.04721.15
5.6.80.0100.03320.42
5.5.350.3830.04320.42
5.5.340.0070.08018.02
5.5.330.0070.05720.13
5.5.320.2100.05720.29
5.5.310.0030.05320.41
5.5.300.0030.05317.95
5.5.290.0070.04017.95
5.5.280.0030.04320.88
5.5.270.0030.05320.62
5.5.260.0100.08320.86
5.5.250.0030.04320.79
5.5.240.0030.07320.09
5.4.450.0400.05719.38
5.4.440.0970.07319.33
5.4.430.0770.06019.59
5.4.420.0830.06019.27
5.4.410.0870.05319.47
5.4.400.0730.05719.29
5.4.390.0930.06019.25
5.4.380.0300.05018.74
5.4.370.0130.05718.79
5.4.360.0200.04718.61
5.4.350.0170.05018.63
5.4.340.0230.04018.80
5.4.320.0070.03712.52
5.4.310.0060.03712.52
5.4.300.0050.04112.52
5.4.290.0100.05012.52
5.4.280.0070.03512.41
5.4.270.0070.07319.09
5.4.260.0100.07719.02
5.4.250.0070.05718.93
5.4.240.0130.05019.00
5.4.230.0070.07318.92
5.4.220.0100.05718.99
5.4.210.0030.05718.64
5.4.200.0270.06018.94
5.4.190.0030.08318.96
5.4.180.0100.07719.01
5.4.170.0070.05718.64
5.4.160.0030.07318.64
5.4.150.0230.06318.73
5.4.140.0070.05316.60
5.4.130.0100.06716.43
5.4.120.0070.05316.61
5.4.110.0030.05716.61
5.4.100.0100.04716.70
5.4.90.0130.04716.55
5.4.80.0070.05016.36
5.4.70.0200.06316.66
5.4.60.0100.05016.54
5.4.50.0170.05716.35
5.4.40.0100.06716.45
5.4.30.0200.06016.38
5.4.20.0170.05316.51
5.4.10.0070.05316.46
5.4.00.0170.04315.89
5.3.290.0080.04112.80
5.3.280.0100.06714.74
5.3.270.0100.05314.70
5.3.260.0070.06714.71
5.3.250.0100.05714.70
5.3.240.0130.07714.61
5.3.230.0030.05714.78
5.3.220.0130.06714.57
5.3.210.0070.07714.76
5.3.200.0130.06014.72
5.3.190.0130.04314.66
5.3.180.0170.06314.71
5.3.170.0030.06714.66
5.3.160.0230.06014.72
5.3.150.0130.05314.48
5.3.140.0100.05314.79
5.3.130.0170.07014.66
5.3.120.0100.07714.58
5.3.110.0100.06014.46
5.3.100.0030.07714.04
5.3.90.0100.05014.01
5.3.80.0100.05714.11
5.3.70.0030.07314.02
5.3.60.0100.07014.12
5.3.50.0100.07014.05
5.3.40.0100.05014.16
5.3.30.0130.04313.94
5.3.20.0130.04713.70
5.3.10.0100.04713.75
5.3.00.0070.06013.66
5.2.170.0100.06011.14
5.2.160.0000.04711.13
5.2.150.0100.04011.32
5.2.140.0070.05711.33
5.2.130.0100.05711.18
5.2.120.0070.04011.28
5.2.110.0100.03711.26
5.2.100.0130.04311.27
5.2.90.0100.03311.27
5.2.80.0030.05011.16
5.2.70.0070.04711.18
5.2.60.0030.04311.05
5.2.50.0100.05311.02
5.2.40.0130.03711.09
5.2.30.0030.04711.20
5.2.20.0030.05710.95
5.2.10.0170.04710.82
5.2.00.0100.03710.57
5.1.60.0000.0409.84
5.1.50.0070.04710.04
5.1.40.0130.03710.18
5.1.30.0030.03710.42
5.1.20.0030.04310.44
5.1.10.0100.03010.14
5.1.00.0070.05010.08
5.0.50.0000.0438.61
5.0.40.0070.0278.58
5.0.30.0030.0478.23
5.0.20.0030.0278.21
5.0.10.0100.0338.15
5.0.00.0100.0508.27
4.4.90.0030.0306.10
4.4.80.0070.0276.10
4.4.70.0100.0236.10
4.4.60.0030.0276.10
4.4.50.0030.0306.10
4.4.40.0000.0476.10
4.4.30.0100.0136.10
4.4.20.0000.0336.10
4.4.10.0000.0336.10
4.4.00.0070.0406.10
4.3.110.0030.0306.10
4.3.100.0030.0306.10
4.3.90.0030.0306.10
4.3.80.0070.0376.10
4.3.70.0030.0306.10
4.3.60.0030.0306.10
4.3.50.0000.0336.09
4.3.40.0000.0436.09
4.3.30.0030.0276.09
4.3.20.0000.0236.09
4.3.10.0000.0236.09
4.3.00.0130.0178.13

preferences:
97.2 ms | 401 KiB | 5 Q