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 echo $key;exit; $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test(); // start class MyClass implements arrayaccess{ public $closure; protected $container = array('arraykey' => 'arraykey2', 'arraykey2' => 'callback'); 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); // I dont really understand what this is doing } public function __toString(){ // Object of class V could not be converted to string; return 'arraykey'; } // 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.40.0120.00318.82
8.3.30.0120.00319.05
8.3.20.0030.00620.04
8.3.10.0040.00422.05
8.3.00.0000.00822.57
8.2.170.0210.00022.96
8.2.160.0130.00020.51
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0070.00426.16
8.2.120.0070.00019.95
8.2.110.0060.00321.18
8.2.100.0120.00318.03
8.2.90.0050.00319.23
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0090.00018.16
8.2.30.0080.00518.20
8.2.20.0060.00317.78
8.2.10.0040.00419.59
8.2.00.0000.00717.85
8.1.270.0040.00422.22
8.1.260.0080.00026.35
8.1.250.0030.00528.09
8.1.240.0030.00722.14
8.1.230.0070.00319.00
8.1.220.0030.00517.74
8.1.210.0000.00918.77
8.1.200.0030.00617.35
8.1.190.0040.00417.41
8.1.180.0080.00018.10
8.1.170.0000.00818.49
8.1.160.0050.00222.04
8.1.150.0000.00818.70
8.1.140.0060.00317.34
8.1.130.0000.00717.91
8.1.120.0050.00317.54
8.1.110.0000.00817.54
8.1.100.0000.00717.46
8.1.90.0050.00517.39
8.1.80.0000.00717.43
8.1.70.0070.00017.46
8.1.60.0040.00417.49
8.1.50.0000.00717.50
8.1.40.0030.00617.58
8.1.30.0000.00817.63
8.1.20.0000.00817.59
8.1.10.0050.00317.48
8.1.00.0000.00917.50
8.0.300.0000.00718.77
8.0.290.0070.00016.75
8.0.280.0000.00818.46
8.0.270.0000.00717.26
8.0.260.0030.00516.95
8.0.250.0000.00716.99
8.0.240.0060.00316.96
8.0.230.0000.00816.93
8.0.220.0080.00016.97
8.0.210.0000.00716.95
8.0.200.0000.00816.92
8.0.190.0060.00316.96
8.0.180.0040.00416.90
8.0.170.0040.00417.04
8.0.160.0070.00017.00
8.0.150.0030.00316.80
8.0.140.0050.00316.96
8.0.130.0030.00313.44
8.0.120.0030.00517.00
8.0.110.0000.00716.86
8.0.100.0070.00016.82
8.0.90.0040.00416.85
8.0.80.0130.00716.94
8.0.70.0040.00416.99
8.0.60.0040.00417.04
8.0.50.0040.00417.04
8.0.30.0120.01017.23
8.0.20.0110.00717.40
8.0.10.0000.00717.05
8.0.00.0110.00816.88
7.4.330.0030.00315.14
7.4.320.0030.00316.61
7.4.300.0030.00316.61
7.4.290.0070.00016.66
7.4.280.0030.00516.48
7.4.270.0080.00016.53
7.4.260.0050.00316.57
7.4.250.0000.00716.39
7.4.240.0030.00516.53
7.4.230.0050.00216.50
7.4.220.0150.00316.55
7.4.210.0060.00916.62
7.4.200.0030.00316.43
7.4.190.0040.00416.33
7.4.160.0090.01516.57
7.4.150.0070.01117.40
7.4.140.0050.01417.86
7.4.130.0080.00916.56
7.4.120.0100.00716.73
7.4.110.0110.00616.45
7.4.100.0110.00716.59
7.4.90.0040.01416.56
7.4.80.0130.00619.39
7.4.70.0070.00716.41
7.4.60.0060.01016.52
7.4.50.0040.00416.67
7.4.40.0090.00622.77
7.4.30.0060.01316.73
7.4.00.0070.00814.93
7.3.330.0030.00313.39
7.3.320.0050.00013.38
7.3.310.0050.00216.36
7.3.300.0070.00016.21
7.3.290.0070.00816.34
7.3.280.0060.01116.38
7.3.270.0060.01217.40
7.3.260.0120.00916.65
7.3.250.0130.00516.48
7.3.240.0170.00616.62
7.3.230.0100.01016.67
7.3.210.0100.00616.58
7.3.200.0100.00719.39
7.3.190.0150.00616.47
7.3.180.0120.00316.36
7.3.170.0140.00316.54
7.3.160.0100.00716.46
7.3.120.0060.01014.86
7.3.110.0100.00715.00
7.3.100.0090.00614.95
7.3.90.0040.01214.96
7.3.80.0060.00614.97
7.3.70.0130.00014.91
7.3.60.0040.00814.76
7.3.50.0030.00914.86
7.3.40.0120.00314.97
7.3.30.0000.00814.60
7.3.20.0030.00916.75
7.3.10.0050.00716.47
7.3.00.0050.00716.72
7.2.330.0100.00716.57
7.2.320.0040.01916.84
7.2.310.0100.00616.77
7.2.300.0110.00716.90
7.2.290.0060.00916.84
7.2.250.0070.01115.23
7.2.240.0080.00815.03
7.2.230.0040.00715.02
7.2.220.0030.01315.34
7.2.210.0030.00915.11
7.2.200.0150.00015.15
7.2.190.0080.00415.02
7.2.180.0000.01315.10
7.2.170.0030.01315.02
7.2.130.0110.00716.50
7.2.120.0090.00916.72
7.2.110.0220.01116.50
7.2.100.0260.00416.62
7.2.90.0190.00816.41
7.2.80.0250.00216.62
7.2.70.0080.01216.74
7.2.60.0150.00816.55
7.2.50.0210.00716.26
7.2.40.0140.00916.32
7.2.30.0030.01416.61
7.2.20.0120.00016.42
7.2.10.0000.01516.65
7.2.00.0150.00418.30
7.1.330.0090.00615.86
7.1.320.0000.01415.65
7.1.310.0000.01115.87
7.1.300.0000.00815.60
7.1.290.0110.00015.80
7.1.280.0000.00815.84
7.1.270.0080.00015.70
7.1.260.0130.00015.45
7.1.250.0180.00615.70
7.1.100.0030.00617.65
7.1.70.0000.00817.35
7.1.60.0070.00419.82
7.1.50.0110.01116.95
7.1.00.0000.08022.28
7.0.200.0110.00816.63
7.0.140.0100.06322.11
7.0.60.0070.07719.95
7.0.50.0130.06017.99
7.0.40.0030.06720.15
7.0.30.0270.06720.34
7.0.20.0230.06320.23
7.0.10.0370.06320.30
7.0.00.0130.04320.10
5.6.280.0070.07021.04
5.6.210.0070.06320.62
5.6.200.0030.04018.18
5.6.190.0000.04320.55
5.6.180.3130.04720.64
5.6.170.0270.06320.55
5.6.160.0070.05320.72
5.6.150.0030.05718.29
5.6.140.0070.04018.15
5.6.130.0130.07318.21
5.6.120.0100.08320.98
5.6.110.0130.03321.02
5.6.100.0070.05720.90
5.6.90.0130.06721.13
5.6.80.0100.06720.36
5.5.350.0030.06020.35
5.5.340.0000.04017.99
5.5.330.0130.07020.21
5.5.320.0300.05320.24
5.5.310.0370.06320.31
5.5.300.0070.08317.96
5.5.290.0000.04718.05
5.5.280.0070.03720.89
5.5.270.0070.04320.89
5.5.260.0130.06020.81
5.5.250.0000.04320.63
5.5.240.0030.06020.28
5.4.450.0830.06019.58
5.4.440.0100.05319.57
5.4.430.0130.07019.43
5.4.420.0230.06019.52
5.4.410.0100.07319.32
5.4.400.2130.00018.88
5.4.390.0670.00018.75
5.4.380.0270.05318.80
5.4.370.0130.05318.59
5.4.360.0130.05318.80
5.4.350.0130.05718.55
5.4.340.0100.05318.74
5.4.320.0060.03712.52
5.4.310.0080.03712.52
5.4.300.0080.03512.52
5.4.290.0100.03612.52
5.4.280.0060.03612.41
5.4.270.0100.07018.65
5.4.260.0100.05319.00
5.4.250.0030.05719.10
5.4.240.0030.06318.64
5.4.230.0170.06018.99
5.4.220.0170.06019.00
5.4.210.0100.08018.65
5.4.200.0200.06018.93
5.4.190.0130.06718.89
5.4.180.0130.07018.83
5.4.170.0070.06318.78
5.4.160.0130.05318.82
5.4.150.0270.05018.92
5.4.140.0200.07016.43
5.4.130.0070.06716.47
5.4.120.0130.04716.41
5.4.110.0200.06716.47
5.4.100.0070.06716.58
5.4.90.0170.04016.52
5.4.80.0100.06316.45
5.4.70.0130.05316.59
5.4.60.0200.05716.32
5.4.50.0070.06716.39
5.4.40.0070.06716.49
5.4.30.0100.06316.32
5.4.20.0070.06016.61
5.4.10.0130.05716.38
5.4.00.0100.05716.03
5.3.290.0100.03712.80
5.3.280.0000.06314.44
5.3.270.0070.05714.62
5.3.260.0070.06714.61
5.3.250.0100.06014.69
5.3.240.0100.05714.80
5.3.230.0270.04714.60
5.3.220.0100.07014.66
5.3.210.0100.05714.43
5.3.200.0100.06014.66
5.3.190.0070.05714.55
5.3.180.0170.05714.59
5.3.170.0100.05314.80
5.3.160.0130.07014.58
5.3.150.0100.08014.41
5.3.140.0100.05314.73
5.3.130.0070.07014.66
5.3.120.0130.05014.64
5.3.110.0130.05714.75
5.3.100.0100.07014.04
5.3.90.0200.05014.26
5.3.80.0300.04713.87
5.3.70.0130.05314.21
5.3.60.0000.06014.10
5.3.50.0100.05713.80
5.3.40.0230.05314.19
5.3.30.0100.06313.94
5.3.20.0230.04313.80
5.3.10.0170.06013.88
5.3.00.0170.05713.88
5.2.170.0030.05011.22
5.2.160.0100.04011.38
5.2.150.0070.04011.23
5.2.140.0100.05310.98
5.2.130.0130.04311.18
5.2.120.0030.04311.06
5.2.110.0000.04711.29
5.2.100.0130.03311.09
5.2.90.0070.06011.01
5.2.80.0170.05311.19
5.2.70.0130.03311.32
5.2.60.0130.03711.14
5.2.50.0170.06011.07
5.2.40.0030.04311.00
5.2.30.0130.04310.88
5.2.20.0070.04310.87
5.2.10.0100.05010.79
5.2.00.0070.05310.71
5.1.60.0030.0409.98
5.1.50.0070.0479.85
5.1.40.0070.0379.91
5.1.30.0070.03710.30
5.1.20.0030.04010.43
5.1.10.0030.05010.02
5.1.00.0100.04710.23
5.0.50.0070.0338.55
5.0.40.0030.0308.38
5.0.30.0070.0508.47
5.0.20.0030.0308.25
5.0.10.0100.0238.02
5.0.00.0000.0578.14
4.4.90.0100.0206.21
4.4.80.0030.0236.16
4.4.70.0070.0236.06
4.4.60.0030.0276.02
4.4.50.0030.0206.01
4.4.40.0030.0375.90
4.4.30.0070.0275.86
4.4.20.0030.0375.89
4.4.10.0030.0305.97
4.4.00.0130.0235.91
4.3.110.0130.0175.84
4.3.100.0030.0305.79
4.3.90.0030.0275.77
4.3.80.0030.0405.82
4.3.70.0070.0235.73
4.3.60.0000.0275.75
4.3.50.0070.0235.75
4.3.40.0000.0475.73
4.3.30.0000.0305.71
4.3.20.0070.0235.71
4.3.10.0000.0305.71
4.3.00.0070.0236.56

preferences:
41.19 ms | 400 KiB | 5 Q