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) { $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.0040.01118.66
8.3.50.0150.00721.99
8.3.40.0150.00018.65
8.3.30.0100.00319.04
8.3.20.0080.00020.22
8.3.10.0000.00722.10
8.3.00.0000.00922.38
8.2.180.0160.00616.63
8.2.170.0100.01022.96
8.2.160.0150.00020.35
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0090.00317.88
8.2.110.0090.00022.19
8.2.100.0080.00319.58
8.2.90.0040.00419.26
8.2.80.0000.00919.55
8.2.70.0030.00617.63
8.2.60.0030.00618.05
8.2.50.0050.00318.07
8.2.40.0030.00518.09
8.2.30.0060.00318.22
8.2.20.0000.00817.82
8.2.10.0060.00319.50
8.2.00.0080.00017.93
8.1.280.0140.00325.92
8.1.270.0070.00023.99
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0090.00023.77
8.1.230.0100.00019.10
8.1.220.0000.00817.78
8.1.210.0050.00318.77
8.1.200.0060.00317.36
8.1.190.0050.00317.63
8.1.180.0050.00318.10
8.1.170.0040.00418.53
8.1.160.0040.00421.96
8.1.150.0000.00818.59
8.1.140.0040.00417.48
8.1.130.0000.00717.87
8.1.120.0040.00417.40
8.1.110.0070.00017.38
8.1.100.0050.00217.51
8.1.90.0040.00717.39
8.1.80.0000.00817.39
8.1.70.0000.00717.45
8.1.60.0000.00817.64
8.1.50.0000.00717.48
8.1.40.0050.00317.58
8.1.30.0040.00417.51
8.1.20.0000.00817.65
8.1.10.0040.00417.61
8.1.00.0050.00317.43
8.0.300.0030.00518.77
8.0.290.0000.00717.18
8.0.280.0000.00718.39
8.0.270.0030.00317.22
8.0.260.0030.00316.84
8.0.250.0000.00716.97
8.0.240.0020.00517.04
8.0.230.0000.00717.11
8.0.220.0040.00416.93
8.0.210.0030.00316.98
8.0.200.0060.00016.95
8.0.190.0040.00416.93
8.0.180.0000.00817.01
8.0.170.0040.00417.04
8.0.160.0050.00217.00
8.0.150.0080.00016.97
8.0.140.0040.00416.94
8.0.130.0000.00613.39
8.0.120.0000.00916.95
8.0.110.0000.00716.93
8.0.100.0000.00716.95
8.0.90.0030.00517.07
8.0.80.0060.01016.93
8.0.70.0040.00416.96
8.0.60.0000.00716.96
8.0.50.0000.00716.87
8.0.30.0020.01717.33
8.0.20.0150.00417.40
8.0.10.0040.00417.07
8.0.00.0110.00817.12
7.4.330.0000.00515.00
7.4.320.0030.00316.58
7.4.300.0060.00016.55
7.4.290.0030.00316.55
7.4.280.0000.00716.54
7.4.270.0030.00316.54
7.4.260.0000.00716.67
7.4.250.0040.00416.59
7.4.240.0040.00316.51
7.4.230.0000.00716.49
7.4.220.0070.01316.49
7.4.210.0090.00816.67
7.4.200.0050.00216.71
7.4.190.0030.00516.80
7.4.160.0080.00816.54
7.4.150.0140.00317.40
7.4.140.0080.01017.86
7.4.130.0160.00516.57
7.4.120.0060.01116.54
7.4.110.0030.01316.64
7.4.100.0090.00916.53
7.4.90.0060.01216.64
7.4.80.0170.00019.39
7.4.70.0110.01016.57
7.4.60.0080.00816.46
7.4.50.0060.00316.68
7.4.40.0110.00422.77
7.4.30.0100.00616.36
7.4.10.0060.01314.68
7.4.00.0060.01114.90
7.3.330.0030.00313.32
7.3.320.0000.00513.40
7.3.310.0070.00016.29
7.3.300.0070.00016.34
7.3.290.0000.01316.29
7.3.280.0080.00816.40
7.3.270.0110.00617.40
7.3.260.0150.00316.34
7.3.250.0090.00916.53
7.3.240.0130.00316.56
7.3.230.0100.00716.46
7.3.210.0070.01116.46
7.3.200.0120.00319.39
7.3.190.0090.01216.59
7.3.180.0090.00616.55
7.3.170.0130.00316.37
7.3.160.0060.00916.30
7.3.130.0070.01014.69
7.3.120.0090.00914.74
7.3.110.0050.01314.74
7.3.100.0040.01114.75
7.3.90.0030.01014.88
7.3.80.0050.01214.84
7.3.70.0050.00614.77
7.3.60.0070.00714.64
7.3.50.0040.00915.03
7.3.40.0040.00814.93
7.3.30.0050.00814.79
7.3.20.0050.01116.58
7.3.10.0080.00716.80
7.3.00.0050.01016.64
7.2.330.0050.01416.90
7.2.320.0090.00916.70
7.2.310.0040.01416.57
7.2.300.0000.01816.82
7.2.290.0090.00616.78
7.2.260.0000.01914.68
7.2.250.0120.00815.08
7.2.240.0110.00615.23
7.2.230.0050.01315.15
7.2.220.0050.00715.10
7.2.210.0070.00715.28
7.2.200.0080.00814.99
7.2.190.0080.00515.10
7.2.180.0040.00914.93
7.2.170.0030.01115.01
7.2.160.0040.01115.03
7.2.150.0060.00616.98
7.2.140.0040.01417.05
7.2.130.0110.00416.97
7.2.120.0070.00716.95
7.2.110.0030.01417.08
7.2.100.0060.01216.85
7.2.90.0110.00717.03
7.2.80.0070.00716.98
7.2.70.0030.01217.08
7.2.60.0070.00717.09
7.2.50.0040.00716.77
7.2.40.0030.01417.10
7.2.30.0090.00916.95
7.2.20.0060.00616.84
7.2.10.0040.01516.91
7.2.00.0060.01118.01
7.1.330.0050.00915.97
7.1.320.0070.00715.78
7.1.310.0070.00515.88
7.1.300.0040.00915.80
7.1.290.0070.00615.72
7.1.280.0030.00815.59
7.1.270.0040.00915.77
7.1.260.0000.01015.95
7.1.250.0060.00915.68
7.1.240.0070.00715.83
7.1.230.0080.00715.77
7.1.220.0070.01015.88
7.1.210.0100.00716.02
7.1.200.0060.00315.70
7.1.190.0090.00615.80
7.1.180.0060.00615.52
7.1.170.0090.00315.91
7.1.160.0100.00715.66
7.1.150.0080.00815.71
7.1.140.0100.00315.78
7.1.130.0030.00915.96
7.1.120.0040.01115.68
7.1.110.0060.00615.89
7.1.100.0030.00817.10
7.1.90.0000.01015.80
7.1.80.0030.00815.83
7.1.70.0050.00516.61
7.1.60.0080.00817.76
7.1.50.0080.00916.24
7.1.40.0000.01316.03
7.1.30.0060.00315.65
7.1.20.0000.01315.95
7.1.10.0040.00715.73
7.1.00.0080.03618.91
7.0.330.0060.00615.22
7.0.320.0060.00615.47
7.0.310.0090.00315.41
7.0.300.0090.00315.33
7.0.290.0000.01415.59
7.0.280.0030.01015.46
7.0.270.0060.01215.47
7.0.260.0030.01215.47
7.0.250.0040.00815.24
7.0.240.0000.01515.63
7.0.230.0070.00715.39
7.0.220.0060.00315.39
7.0.210.0070.00715.36
7.0.200.0080.00516.13
7.0.190.0080.00315.30
7.0.180.0040.00815.42
7.0.170.0070.00715.37
7.0.160.0030.01415.46
7.0.150.0000.01315.50
7.0.140.0020.04218.87
7.0.130.0030.01015.56
7.0.120.0070.01015.42
7.0.110.0070.00715.38
7.0.100.0050.04817.79
7.0.90.0050.02717.77
7.0.80.0110.02017.56
7.0.70.0080.02517.69
7.0.60.0160.02117.71
7.0.50.0030.04317.82
7.0.40.0080.03816.71
7.0.30.0090.03916.82
7.0.20.0050.04016.86
7.0.10.0030.04716.70
7.0.00.0070.03816.68
5.6.400.0030.00614.55
5.6.390.0110.00414.68
5.6.380.0090.00614.53
5.6.370.0100.00314.44
5.6.360.0110.00714.50
5.6.350.0060.01214.45
5.6.340.0040.01214.59
5.6.330.0030.01614.06
5.6.320.0060.00614.60
5.6.310.0070.00714.40
5.6.300.0040.01114.66
5.6.290.0060.00914.59
5.6.280.0050.04217.91
5.6.270.0040.00814.39
5.6.260.0060.00614.40
5.6.250.0140.03817.59
5.6.240.0030.04617.49
5.6.230.0060.03017.53
5.6.220.0080.02517.71
5.6.210.0020.03217.60
5.6.200.0100.03717.80
5.6.190.0060.04517.72
5.6.180.0060.04117.77
5.6.170.0020.03717.65
5.6.160.0080.04417.70
5.6.150.0090.02617.80
5.6.140.0030.03017.81
5.6.130.0040.03717.71
5.6.120.0040.03717.71
5.6.110.0120.03817.73
5.6.100.0070.02717.77
5.6.90.0030.03817.63
5.6.80.0030.04817.47
5.6.70.0030.04017.46
5.6.60.0000.03917.49
5.6.50.0140.03617.37
5.6.40.0100.03417.51
5.6.30.0080.02717.46
5.6.20.0060.04617.44
5.6.10.0100.04017.25
5.6.00.0130.03017.34
5.5.380.0060.03817.55
5.5.370.0060.02617.45
5.5.360.0050.03917.43
5.5.350.0070.03417.52
5.5.340.0080.03817.73
5.5.330.0050.04217.57
5.5.320.0110.05117.63
5.5.310.0050.03517.59
5.5.300.0040.02517.77
5.5.290.0060.03917.66
5.5.280.0030.03817.69
5.5.270.0070.03717.65
5.5.260.0070.03217.42
5.5.250.0080.03817.49
5.5.240.0030.04817.33
5.5.230.0090.03717.25
5.5.220.0090.04017.37
5.5.210.0120.04017.37
5.5.200.0080.03217.21
5.5.190.0050.02817.24
5.5.180.0070.04317.35
5.5.170.0080.00314.39
5.5.160.0040.03817.24
5.5.150.0050.03217.29
5.5.140.0070.02717.29
5.5.130.0100.03917.14
5.5.120.0130.03517.23
5.5.110.0120.04217.17
5.5.100.0090.03917.21
5.5.90.0120.03317.11
5.5.80.0070.03517.18
5.5.70.0110.02717.14
5.5.60.0030.04317.15
5.5.50.0070.03017.36
5.5.40.0080.04317.15
5.5.30.0060.02417.35
5.5.20.0080.04417.17
5.5.10.0040.02517.07
5.5.00.0020.03517.35
5.4.450.0060.02116.13
5.4.440.0080.02316.14
5.4.430.0010.02616.12
5.4.420.0070.03515.98
5.4.410.0080.02115.98
5.4.400.0090.03915.88
5.4.390.0070.02315.95
5.4.380.0050.03115.88
5.4.370.0090.04215.79
5.4.360.0050.04115.93
5.4.350.0090.03515.96
5.4.340.0100.04315.92
5.4.330.0040.00812.72
5.4.320.0050.03515.95
5.4.310.0030.03015.88
5.4.300.0050.04215.82
5.4.290.0050.03815.78
5.4.280.0050.04015.92
5.4.270.0060.03115.78
5.4.260.0050.03315.88
5.4.250.0020.04315.87
5.4.240.0070.04015.88
5.4.230.0070.03715.88
5.4.220.0090.03515.79
5.4.210.0070.03515.92
5.4.200.0060.04115.81
5.4.190.0030.04115.79
5.4.180.0080.03215.98
5.4.170.0050.03615.90
5.4.160.0030.04215.90
5.4.150.0050.02015.91
5.4.140.0060.03814.57
5.4.130.0020.02714.61
5.4.120.0070.03514.60
5.4.110.0020.03014.56
5.4.100.0080.03714.64
5.4.90.0070.02214.58
5.4.80.0040.04114.56
5.4.70.0030.04314.63
5.4.60.0080.03514.54
5.4.50.0030.02514.57
5.4.40.0120.03314.54
5.4.30.0050.03014.60
5.4.20.0080.02314.56
5.4.10.0080.02114.51
5.4.00.0050.02314.23
5.3.290.0070.04313.69
5.3.280.0050.02113.67
5.3.270.0050.03913.74
5.3.260.0100.03513.72
5.3.250.0000.03813.68
5.3.240.0060.02213.72
5.3.230.0030.04113.63
5.3.220.0030.04313.62
5.3.210.0020.04613.64
5.3.200.0050.02513.69
5.3.190.0070.03813.63
5.3.180.0030.03413.68
5.3.170.0060.02913.67
5.3.160.0030.04313.68
5.3.150.0020.02913.72
5.3.140.0050.03813.66
5.3.130.0040.03813.69
5.3.120.0050.02713.67
5.3.110.0080.02213.71
5.3.100.0020.02713.37
5.3.90.0070.03213.38
5.3.80.0050.03413.40
5.3.70.0050.03813.45
5.3.60.0060.02313.36
5.3.50.0040.03713.41
5.3.40.0010.02513.29
5.3.30.0020.02513.26
5.3.20.0030.04313.21
5.3.10.0030.02813.21
5.3.00.0000.02913.13
5.2.170.0030.06711.21
5.2.160.0070.05711.15
5.2.150.0070.04011.05
5.2.140.0000.05711.05
5.2.130.0070.04011.25
5.2.120.0030.03711.18
5.2.110.0100.05311.00
5.2.100.0070.03311.04
5.2.90.0070.02711.16
5.2.80.0000.04011.15
5.2.70.0030.05311.19
5.2.60.0000.03710.97
5.2.50.0000.06311.09
5.2.40.0030.06311.15
5.2.30.0070.03310.88
5.2.20.0100.06310.97
5.2.10.0000.06010.79
5.2.00.0100.02710.68
5.1.60.0030.02710.12
5.1.50.0030.02310.10
5.1.40.0030.04310.02
5.1.30.0000.04710.42
5.1.20.0000.05310.45
5.1.10.0030.05310.14
5.1.00.0030.0609.92
5.0.50.0030.0338.64
5.0.40.0000.0478.43
5.0.30.0030.0378.35
5.0.20.0000.0478.24
5.0.10.0030.0338.04
5.0.00.0030.0378.17
4.4.90.0000.0207.94
4.4.80.0030.0307.94
4.4.70.0030.0337.94
4.4.60.0000.0407.94
4.4.50.0030.0277.94
4.4.40.0030.0577.94
4.4.30.0030.0177.94
4.4.20.0000.0237.94
4.4.10.0030.0277.94
4.4.00.0000.0277.94
4.3.110.0030.0377.94
4.3.100.0000.0377.94
4.3.90.0070.0137.94
4.3.80.0030.0437.94
4.3.70.0000.0177.94
4.3.60.0070.0337.94
4.3.50.0000.0237.94
4.3.40.0070.0277.94
4.3.30.0000.0207.94
4.3.20.0000.0177.94
4.3.10.0000.0337.94
4.3.00.0000.0307.94

preferences:
53.33 ms | 400 KiB | 5 Q