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{ protected $container = array('arraykey' => 'arraykey2', 'arraykey2' => 'callback'); public $closure; 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 = $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.60.0120.00918.53
8.3.50.0090.01222.17
8.3.40.0110.00318.97
8.3.30.0070.00719.08
8.3.20.0070.00020.31
8.3.10.0080.00022.13
8.3.00.0040.00422.44
8.2.180.0150.00416.50
8.2.170.0210.00022.96
8.2.160.0090.00420.43
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00317.75
8.2.110.0030.00622.29
8.2.100.0030.00919.51
8.2.90.0000.00719.23
8.2.80.0030.00517.97
8.2.70.0060.00317.88
8.2.60.0040.00417.93
8.2.50.0090.00018.07
8.2.40.0030.00618.16
8.2.30.0000.01018.13
8.2.20.0080.00017.79
8.2.10.0040.00419.66
8.2.00.0040.00417.71
8.1.280.0040.01225.92
8.1.270.0060.00321.92
8.1.260.0050.00326.35
8.1.250.0000.00828.09
8.1.240.0070.00323.76
8.1.230.0040.00719.12
8.1.220.0000.00817.79
8.1.210.0000.00818.77
8.1.200.0090.00017.22
8.1.190.0000.00817.53
8.1.180.0060.00318.10
8.1.170.0030.00518.53
8.1.160.0000.00923.79
8.1.150.0030.00518.68
8.1.140.0000.00717.31
8.1.130.0070.00017.88
8.1.120.0040.00417.38
8.1.110.0070.00017.37
8.1.100.0040.00417.47
8.1.90.0070.00417.45
8.1.80.0080.00017.48
8.1.70.0000.00717.44
8.1.60.0040.00417.58
8.1.50.0070.00017.52
8.1.40.0040.00417.42
8.1.30.0030.00517.68
8.1.20.0060.00317.61
8.1.10.0040.00417.58
8.1.00.0040.00417.51
8.0.300.0070.00018.77
8.0.290.0070.00017.18
8.0.280.0000.00818.38
8.0.270.0040.00417.17
8.0.260.0000.00716.90
8.0.250.0000.00716.94
8.0.240.0070.00316.98
8.0.230.0030.00317.01
8.0.220.0000.00716.95
8.0.210.0030.00316.88
8.0.200.0060.00017.04
8.0.190.0040.00417.01
8.0.180.0040.00416.98
8.0.170.0000.00716.93
8.0.160.0000.00817.01
8.0.150.0000.00916.93
8.0.140.0040.00416.98
8.0.130.0000.00613.37
8.0.120.0000.00816.84
8.0.110.0040.00416.85
8.0.100.0000.00716.82
8.0.90.0000.00716.84
8.0.80.0030.01317.00
8.0.70.0080.00016.87
8.0.60.0070.00016.91
8.0.50.0000.00716.95
8.0.30.0110.01117.11
8.0.20.0100.00917.40
8.0.10.0080.00016.96
8.0.00.0080.01316.87
7.4.330.0000.00615.00
7.4.320.0040.00416.66
7.4.300.0030.00316.61
7.4.290.0070.00016.59
7.4.280.0050.00216.50
7.4.270.0000.00716.64
7.4.260.0040.00416.53
7.4.250.0040.00416.58
7.4.240.0020.00516.58
7.4.230.0000.00816.54
7.4.220.0090.00616.45
7.4.210.0080.00616.65
7.4.200.0000.00716.43
7.4.190.0000.00816.74
7.4.160.0030.01716.43
7.4.150.0150.00917.40
7.4.140.0130.00817.86
7.4.130.0070.01116.50
7.4.120.0110.00716.63
7.4.110.0130.00316.66
7.4.100.0110.01116.57
7.4.90.0110.00716.50
7.4.80.0110.00719.39
7.4.70.0090.00616.46
7.4.60.0060.00916.48
7.4.50.0000.00816.38
7.4.40.0070.00722.77
7.4.30.0110.00716.59
7.4.00.0000.01514.95
7.3.330.0050.00013.46
7.3.320.0030.00313.23
7.3.310.0050.00316.40
7.3.300.0030.00316.38
7.3.290.0040.01116.42
7.3.280.0090.00916.31
7.3.270.0140.00417.40
7.3.260.0070.01016.65
7.3.250.0110.00716.47
7.3.240.0100.01016.41
7.3.230.0070.01016.46
7.3.210.0100.01316.63
7.3.200.0130.00319.39
7.3.190.0030.01316.63
7.3.180.0100.00616.35
7.3.170.0060.01216.36
7.3.160.0120.00616.46
7.3.120.0060.01214.48
7.3.110.0100.01014.91
7.3.100.0090.00914.73
7.3.90.0000.01214.94
7.3.80.0070.01014.77
7.3.70.0080.00614.96
7.3.60.0030.01014.65
7.3.50.0040.00814.69
7.3.40.0060.00314.48
7.3.30.0070.01014.75
7.3.20.0060.00316.36
7.3.10.0080.00416.55
7.3.00.0030.00716.71
7.2.330.0070.01016.47
7.2.320.0110.00816.57
7.2.310.0080.00816.81
7.2.300.0090.00916.95
7.2.290.0100.01016.85
7.2.240.0110.00714.87
7.2.230.0110.00415.21
7.2.220.0050.00515.04
7.2.210.0070.00714.83
7.2.200.0040.01214.94
7.2.190.0060.00315.16
7.2.180.0040.00815.09
7.2.170.0070.00714.89
7.2.160.0100.00315.01
7.2.150.0000.00916.79
7.2.140.0090.00416.98
7.2.130.0060.00917.10
7.2.120.0100.00716.98
7.2.110.0000.01816.72
7.2.100.0070.01017.07
7.2.90.0040.00816.64
7.2.80.0140.00016.95
7.2.70.0090.00316.78
7.2.60.0040.00717.03
7.2.50.0040.01216.79
7.2.40.0060.01116.77
7.2.30.0070.01016.95
7.2.20.0040.01117.07
7.2.10.0100.00716.97
7.2.00.0070.00418.09
7.1.330.0030.01415.66
7.1.320.0030.00715.80
7.1.310.0030.00715.67
7.1.300.0110.00415.69
7.1.290.0000.00915.90
7.1.280.0120.00415.73
7.1.270.0070.00715.71
7.1.260.0030.01015.77
7.1.250.0070.00715.56
7.1.100.0000.01418.18
7.1.70.0000.00717.14
7.1.60.0030.00919.82
7.1.50.0100.01616.94
7.1.00.0070.07322.36
7.0.200.0100.00316.87
7.0.140.0100.06322.01
7.0.60.0070.05019.98
7.0.50.0070.05017.93
7.0.40.0030.08720.04
7.0.30.0200.04020.21
7.0.20.0300.07320.07
7.0.10.0070.08020.12
7.0.00.0100.05720.09
5.6.280.0000.07020.84
5.6.210.0030.05720.71
5.6.200.0030.06718.14
5.6.190.0070.08720.50
5.6.180.0100.08020.41
5.6.170.0230.08720.47
5.6.160.0070.03720.50
5.6.150.0000.05718.18
5.6.140.0030.04018.19
5.6.130.0030.07318.28
5.6.120.0030.08320.95
5.6.110.0070.08721.00
5.6.100.0030.06021.13
5.6.90.0030.08321.14
5.6.80.0070.04320.37
5.5.350.0070.08020.48
5.5.340.0100.07317.95
5.5.330.0130.06320.42
5.5.320.0270.05320.38
5.5.310.0400.06320.34
5.5.300.0130.05717.96
5.5.290.0100.05718.04
5.5.280.0100.07720.75
5.5.270.0100.07320.78
5.5.260.0130.08020.89
5.5.250.0170.05020.61
5.5.240.0000.03320.28
5.4.450.0530.03719.30
5.4.440.1230.04019.40
5.4.430.0770.06319.47
5.4.420.0570.04319.52
5.4.410.0100.04319.33
5.4.400.0500.04019.25
5.4.390.0770.04719.32
5.4.380.0430.04718.81
5.4.370.0330.06018.78
5.4.360.0370.04318.78
5.4.350.0330.05718.77
5.4.340.0270.05318.83
5.4.320.0120.03712.52
5.4.310.0070.03912.51
5.4.300.0060.04312.52
5.4.290.0100.04612.51
5.4.280.0060.03612.41
5.4.270.0100.06318.94
5.4.260.0130.07019.02
5.4.250.0200.04718.65
5.4.240.0100.07018.80
5.4.230.0100.06018.98
5.4.220.0130.07718.94
5.4.210.0100.05319.00
5.4.200.0230.05018.79
5.4.190.0170.07718.76
5.4.180.0170.04318.93
5.4.170.0070.06718.79
5.4.160.0300.05018.97
5.4.150.0130.05718.99
5.4.140.0070.06016.41
5.4.130.0070.06016.39
5.4.120.0130.04716.58
5.4.110.0200.06316.62
5.4.100.0230.06016.53
5.4.90.0100.05316.54
5.4.80.0130.05316.45
5.4.70.0100.05316.52
5.4.60.0130.06716.39
5.4.50.0130.05016.45
5.4.40.0030.05016.44
5.4.30.0070.05016.31
5.4.20.0100.06716.46
5.4.10.0130.06316.47
5.4.00.0130.05315.99
5.3.290.0050.04912.80
5.3.280.0100.07314.68
5.3.270.0100.06714.61
5.3.260.0070.06714.80
5.3.250.0100.05014.80
5.3.240.0000.05714.64
5.3.230.0100.05314.60
5.3.220.0130.07014.62
5.3.210.0070.08314.76
5.3.200.0070.05314.80
5.3.190.0030.08314.48
5.3.180.0130.06014.66
5.3.170.0070.05014.64
5.3.160.0030.05714.48
5.3.150.0070.05314.74
5.3.140.0200.06014.65
5.3.130.0130.05714.79
5.3.120.0030.05714.54
5.3.110.0030.06314.70
5.3.100.0070.05314.14
5.3.90.0170.05014.26
5.3.80.0030.06014.10
5.3.70.0000.05714.00
5.3.60.0030.06014.09
5.3.50.0130.06314.07
5.3.40.0070.05714.06
5.3.30.0030.05014.15
5.3.20.0000.05713.80
5.3.10.0100.06713.68
5.3.00.0170.06013.66
5.2.170.0100.04311.16
5.2.160.0070.04711.32
5.2.150.0100.05311.16
5.2.140.0000.05311.14
5.2.130.0030.04711.11
5.2.120.0130.05011.18
5.2.110.0170.04011.10
5.2.100.0030.04311.09
5.2.90.0170.05011.01
5.2.80.0070.05711.27
5.2.70.0130.05711.16
5.2.60.0000.05311.15
5.2.50.0100.05311.00
5.2.40.0000.06010.91
5.2.30.0030.04310.93
5.2.20.0170.03711.19
5.2.10.0130.03310.82
5.2.00.0070.04710.80
5.1.60.0100.03310.25
5.1.50.0030.04010.10
5.1.40.0100.04310.09
5.1.30.0100.03710.43
5.1.20.0000.07010.53
5.1.10.0100.03710.32
5.1.00.0030.04010.07
5.0.50.0030.0378.61
5.0.40.0070.0238.39
5.0.30.0130.0338.30
5.0.20.0100.0308.43
5.0.10.0000.0308.25
5.0.00.0100.0438.23
4.4.90.0100.0206.31
4.4.80.0130.0206.31
4.4.70.0030.0206.31
4.4.60.0070.0236.31
4.4.50.0030.0206.31
4.4.40.0100.0406.31
4.4.30.0030.0206.31
4.4.20.0030.0236.31
4.4.10.0070.0236.31
4.4.00.0000.0406.31
4.3.110.0000.0236.31
4.3.100.0100.0236.31
4.3.90.0070.0336.31
4.3.80.0070.0406.31
4.3.70.0000.0236.31
4.3.60.0000.0276.31
4.3.50.0000.0276.31
4.3.40.0000.0376.31
4.3.30.0030.0206.31
4.3.20.0030.0276.31
4.3.10.0000.0236.31
4.3.00.0070.01315.57

preferences:
57.09 ms | 401 KiB | 5 Q