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); // I dont really understand what this is doing $this->container = array('0' => '1', '1' => 'callback'); } public function __toString(){ // Object of class V could not be converted to string; return '0'; } // 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; } } $a = new MyClass($test); print_r($a['1']);exit; //$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.0110.00718.31
8.3.50.0070.01122.05
8.3.40.0090.00618.71
8.3.30.0140.00019.11
8.3.20.0070.00020.25
8.3.10.0040.00422.18
8.3.00.0040.00422.39
8.2.180.0060.01216.63
8.2.170.0060.01222.96
8.2.160.0060.00920.39
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00819.50
8.2.110.0060.00322.26
8.2.100.0040.00819.70
8.2.90.0030.00619.25
8.2.80.0090.00018.05
8.2.70.0030.00617.63
8.2.60.0040.00417.93
8.2.50.0000.00818.07
8.2.40.0050.00318.34
8.2.30.0100.00018.20
8.2.20.0000.00717.66
8.2.10.0000.00817.73
8.2.00.0000.00717.69
8.1.280.0210.00325.92
8.1.270.0040.00422.26
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00623.77
8.1.230.0110.00019.15
8.1.220.0080.00017.77
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0040.00417.43
8.1.180.0040.00418.10
8.1.170.0050.00318.65
8.1.160.0050.00221.94
8.1.150.0030.00618.61
8.1.140.0040.00417.34
8.1.130.0000.00817.80
8.1.120.0040.00317.52
8.1.110.0020.00517.47
8.1.100.0040.00417.38
8.1.90.0000.00717.46
8.1.80.0000.00717.36
8.1.70.0030.00317.47
8.1.60.0080.00317.48
8.1.50.0040.00417.54
8.1.40.0030.00517.42
8.1.30.0000.00817.52
8.1.20.0000.00817.68
8.1.10.0040.00417.66
8.1.00.0060.00317.48
8.0.300.0070.00018.77
8.0.290.0040.00417.16
8.0.280.0000.00818.49
8.0.270.0030.00317.34
8.0.260.0040.00416.88
8.0.250.0070.00017.06
8.0.240.0060.00617.03
8.0.230.0000.00717.06
8.0.220.0030.00316.95
8.0.210.0000.00716.85
8.0.200.0030.00317.05
8.0.190.0070.00017.00
8.0.180.0000.00816.99
8.0.170.0040.00416.97
8.0.160.0070.00016.85
8.0.150.0030.00316.77
8.0.140.0000.00716.84
8.0.130.0060.00013.36
8.0.120.0070.00016.77
8.0.110.0040.00416.82
8.0.100.0000.00816.98
8.0.90.0000.00716.92
8.0.80.0060.00917.01
8.0.70.0050.00216.90
8.0.60.0070.00016.85
8.0.50.0000.00716.95
8.0.30.0090.00917.18
8.0.20.0110.01017.40
8.0.10.0000.00717.15
8.0.00.0110.00616.61
7.4.330.0060.00015.00
7.4.320.0030.00316.52
7.4.300.0040.00416.58
7.4.290.0030.00316.49
7.4.280.0000.00716.61
7.4.270.0070.00016.62
7.4.260.0030.00316.63
7.4.250.0070.00016.52
7.4.240.0020.00516.58
7.4.230.0030.00316.71
7.4.220.0100.00716.55
7.4.210.0120.00516.59
7.4.200.0000.00716.72
7.4.190.0040.00416.47
7.4.160.0100.00616.55
7.4.150.0220.00317.40
7.4.140.0140.00917.86
7.4.130.0100.00816.45
7.4.120.0050.01416.66
7.4.110.0090.00916.65
7.4.100.0070.01116.46
7.4.90.0100.00716.68
7.4.80.0060.01219.39
7.4.70.0100.00616.68
7.4.60.0110.00616.59
7.4.50.0040.00416.48
7.4.40.0030.01322.77
7.4.30.0160.00016.58
7.4.10.0030.01614.75
7.4.00.0060.01114.98
7.3.330.0000.00513.40
7.3.320.0050.00013.47
7.3.310.0070.00016.26
7.3.300.0030.00316.44
7.3.290.0090.00616.45
7.3.280.0100.00616.36
7.3.270.0120.00617.40
7.3.260.0090.00916.58
7.3.250.0070.01216.34
7.3.240.0120.00616.37
7.3.230.0120.01216.47
7.3.210.0070.01116.61
7.3.200.0100.00719.39
7.3.190.0040.01816.49
7.3.180.0130.00316.36
7.3.170.0060.00916.48
7.3.160.0060.01116.37
7.3.130.0070.01014.86
7.3.120.0080.00614.89
7.3.110.0080.01014.90
7.3.100.0070.00814.80
7.3.90.0090.00514.88
7.3.80.0090.00614.86
7.3.70.0060.00814.83
7.3.60.0090.00514.69
7.3.50.0050.01014.87
7.3.40.0020.00714.76
7.3.30.0080.00614.76
7.3.20.0030.00816.79
7.3.10.0080.00516.61
7.3.00.0040.00916.56
7.2.330.0140.00416.62
7.2.320.0180.00016.87
7.2.310.0030.01716.87
7.2.300.0030.01416.74
7.2.290.0090.00916.62
7.2.260.0100.01015.07
7.2.250.0080.00915.06
7.2.240.0090.00815.15
7.2.230.0030.00914.90
7.2.220.0090.00715.18
7.2.210.0020.01214.83
7.2.200.0070.00915.18
7.2.190.0070.00815.05
7.2.180.0050.01015.11
7.2.170.0070.00815.04
7.2.160.0070.00715.08
7.2.150.0050.00516.82
7.2.140.0090.00316.76
7.2.130.0050.00817.01
7.2.120.0040.01016.95
7.2.110.0110.00317.04
7.2.100.0080.00516.96
7.2.90.0000.01516.94
7.2.80.0080.00616.87
7.2.70.0080.00616.88
7.2.60.0060.00716.94
7.2.50.0000.01116.88
7.2.40.0030.01317.01
7.2.30.0020.01216.98
7.2.20.0060.00716.91
7.2.10.0070.00716.96
7.2.00.0040.00617.78
7.1.330.0070.00715.87
7.1.320.0070.00815.62
7.1.310.0080.00715.85
7.1.300.0090.00515.82
7.1.290.0030.01015.79
7.1.280.0040.00915.67
7.1.270.0080.00315.88
7.1.260.0060.00415.80
7.1.250.0060.00815.77
7.1.240.0040.00715.71
7.1.230.0060.00615.98
7.1.220.0000.01415.49
7.1.210.0130.00315.76
7.1.200.0030.01115.81
7.1.190.0040.00815.98
7.1.180.0030.00915.82
7.1.170.0060.00915.98
7.1.160.0050.00515.64
7.1.150.0030.01015.69
7.1.140.0090.00015.72
7.1.130.0040.00815.71
7.1.120.0000.01415.70
7.1.110.0060.00616.01
7.1.100.0050.00917.04
7.1.90.0060.00315.88
7.1.80.0040.00815.82
7.1.70.0050.00716.35
7.1.60.0050.01417.74
7.1.50.0050.01116.18
7.1.40.0000.01215.73
7.1.30.0040.01115.75
7.1.20.0060.00615.83
7.1.10.0100.00315.80
7.1.00.0050.04019.06
7.0.330.0060.00615.17
7.0.320.0070.00715.17
7.0.310.0070.00715.26
7.0.300.0030.01015.50
7.0.290.0030.00915.27
7.0.280.0040.01115.23
7.0.270.0040.01115.65
7.0.260.0070.00415.35
7.0.250.0030.01015.52
7.0.240.0030.00815.23
7.0.230.0040.00715.49
7.0.220.0060.00615.56
7.0.210.0070.01015.20
7.0.200.0030.00516.03
7.0.190.0080.00415.47
7.0.180.0090.00415.49
7.0.170.0100.00315.48
7.0.160.0030.01015.52
7.0.150.0140.00015.51
7.0.140.0040.03518.86
7.0.130.0040.01115.57
7.0.120.0040.00815.52
7.0.110.0030.01015.44
7.0.100.0110.00315.53
7.0.90.0100.00315.33
7.0.80.0060.00615.47
7.0.70.0070.01015.27
7.0.60.0070.04417.64
7.0.50.0050.03316.57
7.0.40.0060.04116.60
7.0.30.0150.03116.87
7.0.20.0150.03716.74
7.0.10.0180.02816.88
7.0.00.0060.04116.65
5.6.400.0080.00814.34
5.6.390.0000.01414.54
5.6.380.0060.00614.22
5.6.370.0000.01214.56
5.6.360.0030.01014.54
5.6.350.0060.00614.56
5.6.340.0000.01214.05
5.6.330.0000.01314.59
5.6.320.0110.00414.27
5.6.310.0070.01014.67
5.6.300.0030.00914.32
5.6.290.0040.00414.58
5.6.280.0050.04017.87
5.6.270.0060.00914.34
5.6.260.0100.00714.54
5.6.250.0080.00814.63
5.6.240.0060.01014.34
5.6.230.0060.00914.20
5.6.220.0060.00914.23
5.6.210.0030.04917.49
5.6.200.0080.02016.25
5.6.190.0100.04417.40
5.6.180.1580.02317.49
5.6.170.0170.02717.29
5.6.160.0030.04917.55
5.6.150.0070.04316.38
5.6.140.0020.02816.31
5.6.130.0070.03716.15
5.6.120.0070.04817.76
5.6.110.0090.01817.77
5.6.100.0040.02717.67
5.6.90.0060.02517.86
5.6.80.0070.03517.50
5.6.70.0220.03517.37
5.6.60.0060.00914.46
5.6.50.0000.01114.46
5.6.40.0070.00714.48
5.6.30.0060.00614.30
5.6.20.0100.00314.35
5.6.10.0000.01214.41
5.6.00.0050.00514.40
5.5.380.0090.00314.34
5.5.370.0060.00914.66
5.5.360.0060.01014.18
5.5.350.0070.02217.39
5.5.340.0020.04616.25
5.5.330.0100.04217.35
5.5.320.0180.02717.33
5.5.310.0180.03817.38
5.5.300.0060.03816.29
5.5.290.0050.04716.09
5.5.280.0070.04217.61
5.5.270.0080.04517.71
5.5.260.0150.03517.75
5.5.250.0050.02517.40
5.5.240.0030.02317.04
5.5.230.0080.00814.39
5.5.220.0110.00714.29
5.5.210.0000.01014.48
5.5.200.0030.00714.31
5.5.190.0030.00914.55
5.5.180.0080.00414.49
5.5.170.0040.01114.46
5.5.160.0080.00414.31
5.5.150.0000.01614.53
5.5.140.0060.00914.58
5.5.130.0040.01114.41
5.5.120.0060.00914.31
5.5.110.0060.00314.44
5.5.100.0030.01014.52
5.5.90.0030.00714.45
5.5.80.0030.01314.53
5.5.70.0070.00714.17
5.5.60.0090.00614.48
5.5.50.0040.00814.37
5.5.40.0000.01614.09
5.5.30.0060.01014.42
5.5.20.0000.01514.41
5.5.10.0040.00714.04
5.5.00.0070.00714.55
5.4.450.0300.03215.86
5.4.440.0050.03315.64
5.4.430.0120.03515.82
5.4.420.0120.03115.79
5.4.410.0050.03415.63
5.4.400.0450.00415.49
5.4.390.0490.00115.44
5.4.380.0160.02815.45
5.4.370.0110.02715.42
5.4.360.0100.02915.32
5.4.350.0100.02815.43
5.4.340.0050.03115.43
5.4.330.0060.00012.14
5.4.320.0080.02412.33
5.4.310.0070.02412.33
5.4.300.0060.02512.33
5.4.290.0040.02812.33
5.4.280.0050.02312.28
5.4.270.0090.03715.56
5.4.260.0100.02815.62
5.4.250.0060.03015.54
5.4.240.0110.02715.54
5.4.230.0040.04015.55
5.4.220.0140.02715.57
5.4.210.0100.02515.62
5.4.200.0130.03515.62
5.4.190.0170.02615.54
5.4.180.0070.03615.62
5.4.170.0050.03315.60
5.4.160.0100.02615.39
5.4.150.0050.04015.55
5.4.140.0050.04014.29
5.4.130.0120.02714.26
5.4.120.0070.03814.27
5.4.110.0070.03714.36
5.4.100.0080.03114.41
5.4.90.0060.02814.28
5.4.80.0070.02714.25
5.4.70.0080.02814.28
5.4.60.0100.02714.38
5.4.50.0020.03114.26
5.4.40.0050.02914.37
5.4.30.0070.03014.25
5.4.20.0120.03514.24
5.4.10.0070.03814.25
5.4.00.0120.02514.02
5.3.290.0050.02312.47
5.3.280.0030.04313.42
5.3.270.0100.03313.47
5.3.260.0070.03813.47
5.3.250.0050.03213.39
5.3.240.0090.02813.43
5.3.230.0080.02913.47
5.3.220.0080.03213.40
5.3.210.0070.02713.43
5.3.200.0070.03913.47
5.3.190.0060.04213.32
5.3.180.0130.03213.44
5.3.170.0030.02813.31
5.3.160.0100.02513.47
5.3.150.0050.03313.28
5.3.140.0070.03313.37
5.3.130.0070.04013.44
5.3.120.0050.02813.27
5.3.110.0050.03813.36
5.3.100.0050.03213.01
5.3.90.0050.03913.20
5.3.80.0030.03813.17
5.3.70.0130.03113.13
5.3.60.0110.02113.16
5.3.50.0130.02513.10
5.3.40.0080.03813.17
5.3.30.0080.03613.06
5.3.20.0020.03812.94
5.3.10.0070.03312.99
5.3.00.0100.02612.99
5.2.170.0030.04311.38
5.2.160.0070.05711.14
5.2.150.0000.05011.22
5.2.140.0130.05011.11
5.2.130.0030.04311.20
5.2.120.0070.04711.29
5.2.110.0070.05011.17
5.2.100.0070.05711.06
5.2.90.0130.04711.33
5.2.80.0170.04711.19
5.2.70.0030.04311.09
5.2.60.0030.04311.05
5.2.50.0070.04311.12
5.2.40.0100.05310.96
5.2.30.0070.04311.05
5.2.20.0030.05311.14
5.2.10.0100.03710.95
5.2.00.0030.04710.89
5.1.60.0130.0409.96
5.1.50.0000.03710.00
5.1.40.0030.03310.23
5.1.30.0030.04010.43
5.1.20.0070.03710.45
5.1.10.0130.03010.14
5.1.00.0000.04310.28
5.0.50.0100.0338.51
5.0.40.0170.0208.47
5.0.30.0030.0438.32
5.0.20.0000.0308.21
5.0.10.0030.0378.28
5.0.00.0030.0408.13
4.4.90.0070.0205.82
4.4.80.0070.0205.85
4.4.70.0030.0275.86
4.4.60.0030.0205.85
4.4.50.0170.0175.85
4.4.40.0030.0375.87
4.4.30.0000.0235.81
4.4.20.0030.0206.02
4.4.10.0070.0175.91
4.4.00.0070.0305.86
4.3.110.0030.0235.74
4.3.100.0000.0305.89
4.3.90.0100.0135.77
4.3.80.0030.0435.72
4.3.70.0000.0235.75
4.3.60.0070.0135.71
4.3.50.0100.0175.72
4.3.40.0070.0375.78
4.3.30.0030.0205.64
4.3.20.0000.0275.64
4.3.10.0030.0205.64
4.3.00.0130.0176.52

preferences:
40.3 ms | 401 KiB | 5 Q