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('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; } } $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.00618.56
8.3.50.0140.00421.86
8.3.40.0120.00318.82
8.3.30.0090.00619.09
8.3.20.0050.00320.33
8.3.10.0060.00322.21
8.3.00.0000.00822.50
8.2.180.0130.01016.88
8.2.170.0070.00722.96
8.2.160.0100.00320.39
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00019.48
8.2.110.0070.00322.11
8.2.100.0030.00919.51
8.2.90.0040.00419.23
8.2.80.0000.00817.97
8.2.70.0060.00317.38
8.2.60.0090.00017.80
8.2.50.0030.00518.07
8.2.40.0000.00818.09
8.2.30.0080.00318.04
8.2.20.0040.00417.82
8.2.10.0050.00319.45
8.2.00.0000.00717.69
8.1.280.0040.01425.92
8.1.270.0040.00422.20
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0000.00923.92
8.1.230.0000.01119.04
8.1.220.0050.00317.79
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0060.00317.41
8.1.180.0050.00318.10
8.1.170.0040.00418.63
8.1.160.0000.00822.02
8.1.150.0040.00418.68
8.1.140.0040.00417.55
8.1.130.0030.00317.76
8.1.120.0040.00417.52
8.1.110.0000.00817.50
8.1.100.0070.00017.48
8.1.90.0000.00817.51
8.1.80.0070.00017.50
8.1.70.0050.00217.42
8.1.60.0040.00417.52
8.1.50.0030.00517.45
8.1.40.0060.00317.60
8.1.30.0050.00317.71
8.1.20.0050.00317.68
8.1.10.0030.00617.63
8.1.00.0080.00417.62
8.0.300.0050.00318.77
8.0.290.0050.00217.04
8.0.280.0040.00418.47
8.0.270.0030.00317.30
8.0.260.0000.00716.91
8.0.250.0040.00417.10
8.0.240.0100.00016.89
8.0.230.0030.00316.91
8.0.220.0030.00416.98
8.0.210.0040.00416.89
8.0.200.0030.00316.93
8.0.190.0080.00017.03
8.0.180.0000.00717.05
8.0.170.0040.00417.02
8.0.160.0050.00217.05
8.0.150.0040.00416.90
8.0.140.0040.00416.91
8.0.130.0060.00013.41
8.0.120.0020.00516.87
8.0.110.0070.00017.04
8.0.100.0040.00416.94
8.0.90.0040.00416.82
8.0.80.0100.00717.01
8.0.70.0000.00716.87
8.0.60.0040.00416.92
8.0.50.0000.00717.05
8.0.30.0110.01317.13
8.0.20.0080.01517.40
8.0.10.0030.00517.09
8.0.00.0050.01716.89
7.4.330.0060.00315.00
7.4.320.0030.00316.40
7.4.300.0000.00616.63
7.4.290.0070.00016.49
7.4.280.0030.00316.54
7.4.270.0030.00516.61
7.4.260.0050.00316.51
7.4.250.0000.00716.64
7.4.240.0050.00316.53
7.4.230.0040.00416.51
7.4.220.0070.01016.57
7.4.210.0070.01116.57
7.4.200.0030.00316.59
7.4.190.0000.00816.68
7.4.160.0030.01316.64
7.4.150.0130.00717.40
7.4.140.0100.01217.86
7.4.130.0100.00816.68
7.4.120.0070.01016.56
7.4.110.0160.00316.54
7.4.100.0150.00816.61
7.4.90.0040.01416.46
7.4.80.0040.01419.39
7.4.70.0080.00816.51
7.4.60.0100.00716.44
7.4.50.0090.00016.65
7.4.40.0040.01122.77
7.4.30.0070.01116.63
7.4.00.0030.01414.86
7.3.330.0000.00513.34
7.3.320.0050.00013.47
7.3.310.0030.00316.37
7.3.300.0000.00716.39
7.3.290.0070.00716.36
7.3.280.0070.00916.39
7.3.270.0060.01317.40
7.3.260.0100.00716.42
7.3.250.0130.00716.32
7.3.240.0080.01516.43
7.3.230.0070.01016.60
7.3.210.0090.00916.37
7.3.200.0060.01119.39
7.3.190.0120.01616.54
7.3.180.0100.00616.46
7.3.170.0110.00916.34
7.3.160.0070.01716.39
7.3.120.0170.00014.93
7.3.110.0070.01314.87
7.3.100.0080.00014.74
7.3.90.0080.00015.11
7.3.80.0070.01014.72
7.3.70.0000.01014.61
7.3.60.0040.00414.76
7.3.50.0090.00614.82
7.3.40.0090.00614.86
7.3.30.0080.00414.66
7.3.20.0030.01016.39
7.3.10.0000.01016.67
7.3.00.0030.01416.80
7.2.330.0080.01616.85
7.2.320.0100.01016.82
7.2.310.0110.01116.66
7.2.300.0100.01016.52
7.2.290.0120.01116.59
7.2.240.0060.01215.25
7.2.230.0030.01015.07
7.2.220.0070.01015.35
7.2.210.0090.00615.04
7.2.200.0070.01015.26
7.2.190.0040.01115.24
7.2.180.0070.00714.65
7.2.170.0030.01414.90
7.2.160.0040.00815.17
7.2.150.0060.00617.07
7.2.140.0100.01016.91
7.2.130.0070.01317.18
7.2.120.0040.01517.00
7.2.110.0030.01316.98
7.2.100.0080.00616.64
7.2.90.0040.00716.93
7.2.80.0030.00916.98
7.2.70.0060.00916.88
7.2.60.0070.00716.80
7.2.50.0070.00716.99
7.2.40.0030.00617.09
7.2.30.0060.00616.97
7.2.20.0100.00616.76
7.2.10.0060.00317.03
7.2.00.0080.00618.12
7.1.330.0090.00915.80
7.1.320.0000.00815.79
7.1.310.0090.00615.68
7.1.300.0030.00715.93
7.1.290.0060.00615.75
7.1.280.0040.00715.49
7.1.270.0000.00915.89
7.1.260.0030.01315.79
7.1.250.0000.00815.82
7.1.100.0040.00818.18
7.1.70.0030.00717.00
7.1.60.0080.00619.82
7.1.50.0070.01416.84
7.1.00.0070.07022.45
7.0.200.0030.00916.67
7.0.140.0030.07322.15
7.0.60.0130.08319.88
7.0.50.0070.04017.88
7.0.40.0170.07020.25
7.0.30.0370.07320.24
7.0.20.0230.04020.19
7.0.10.0230.04720.09
7.0.00.0100.08720.25
5.6.280.0030.07320.93
5.6.210.0070.07720.48
5.6.200.0030.04318.14
5.6.190.0100.08020.53
5.6.180.4170.05020.41
5.6.170.0270.04020.47
5.6.160.0070.08020.48
5.6.150.0070.07018.25
5.6.140.0100.06318.23
5.6.130.0100.08018.28
5.6.120.0130.07721.15
5.6.110.0200.07021.00
5.6.100.0070.08321.00
5.6.90.0100.04320.99
5.6.80.0030.08320.55
5.6.70.0330.07320.52
5.5.350.0030.04020.32
5.5.340.0170.03718.09
5.5.330.0030.08720.19
5.5.320.0270.07320.30
5.5.310.0230.05720.38
5.5.300.0170.06717.97
5.5.290.0000.05317.99
5.5.280.0100.08020.91
5.5.270.0030.04020.78
5.5.260.0100.06720.78
5.5.250.0100.05320.71
5.5.240.0030.03720.23
5.4.450.0570.07319.41
5.4.440.0770.06719.41
5.4.430.0170.05319.53
5.4.420.0170.06019.52
5.4.410.0170.06719.41
5.4.400.0900.00018.52
5.4.390.0830.00018.76
5.4.380.0300.04718.61
5.4.370.0200.04718.80
5.4.360.0200.04718.80
5.4.350.0270.04018.79
5.4.340.0130.05718.52
5.4.320.0050.03712.52
5.4.310.0070.04012.52
5.4.300.0040.03912.52
5.4.290.0030.04112.52
5.4.280.0060.03712.41
5.4.270.0030.07718.92
5.4.260.0200.06018.95
5.4.250.0100.05019.02
5.4.240.0200.05018.76
5.4.230.0100.05718.95
5.4.220.0100.07319.00
5.4.210.0130.05018.95
5.4.200.0130.06318.64
5.4.190.0170.04719.01
5.4.180.0100.06318.95
5.4.170.0100.07018.93
5.4.160.0270.06018.95
5.4.150.0270.07318.63
5.4.140.0170.06716.45
5.4.130.0130.04316.59
5.4.120.0100.05016.64
5.4.110.0070.05016.44
5.4.100.0070.06016.38
5.4.90.0030.05016.56
5.4.80.0130.05316.52
5.4.70.0030.08016.66
5.4.60.0170.06316.59
5.4.50.0100.05016.49
5.4.40.0100.06016.64
5.4.30.0070.05016.62
5.4.20.0170.04316.28
5.4.10.0030.08716.50
5.4.00.0030.05315.92
5.3.290.0110.03612.80
5.3.280.0000.06314.71
5.3.270.0030.06014.61
5.3.260.0000.07014.62
5.3.250.0130.06714.45
5.3.240.0100.07314.64
5.3.230.0100.06714.61
5.3.220.0130.04714.68
5.3.210.0030.05714.57
5.3.200.0100.04714.67
5.3.190.0100.05314.72
5.3.180.0200.05714.41
5.3.170.0100.05314.61
5.3.160.0100.07014.59
5.3.150.0170.04314.50
5.3.140.0200.04314.56
5.3.130.0030.07714.70
5.3.120.0170.06314.73
5.3.110.0100.06714.58
5.3.100.0100.04714.14
5.3.90.0130.07014.02
5.3.80.0200.03714.10
5.3.70.0070.05713.94
5.3.60.0130.06014.02
5.3.50.0100.06314.00
5.3.40.0130.06013.99
5.3.30.0030.06713.90
5.3.20.0070.04713.88
5.3.10.0070.06713.76
5.3.00.0070.05313.72
5.2.170.0000.06311.14
5.2.160.0030.04311.14
5.2.150.0070.06011.25
5.2.140.0000.04711.38
5.2.130.0100.05711.27
5.2.120.0070.04011.02
5.2.110.0130.05011.09
5.2.100.0070.05711.17
5.2.90.0170.04711.19
5.2.80.0100.04011.32
5.2.70.0030.06311.17
5.2.60.0070.06011.13
5.2.50.0130.03311.10
5.2.40.0030.04311.09
5.2.30.0030.04711.06
5.2.20.0170.04711.06
5.2.10.0170.04710.88
5.2.00.0100.04710.79
5.1.60.0070.03010.07
5.1.50.0000.0539.99
5.1.40.0130.04310.03
5.1.30.0070.05310.33
5.1.20.0100.04310.53
5.1.10.0000.04010.04
5.1.00.0070.04010.00
5.0.50.0000.0408.56
5.0.40.0030.0338.49
5.0.30.0070.0578.30
5.0.20.0030.0338.30
5.0.10.0030.0408.18
5.0.00.0070.0408.26
4.4.90.0070.0305.84
4.4.80.0070.0275.83
4.4.70.0000.0275.84
4.4.60.0100.0175.89
4.4.50.0030.0235.86
4.4.40.0030.0335.89
4.4.30.0030.0205.80
4.4.20.0130.0205.87
4.4.10.0030.0205.97
4.4.00.0000.0435.84
4.3.110.0030.0305.74
4.3.100.0030.0235.85
4.3.90.0030.0205.74
4.3.80.0030.0305.80
4.3.70.0000.0235.77
4.3.60.0000.0235.77
4.3.50.0070.0235.74
4.3.40.0000.0475.78
4.3.30.0000.0235.71
4.3.20.0000.0235.71
4.3.10.0070.0235.71
4.3.00.0100.0236.54

preferences:
56.17 ms | 401 KiB | 5 Q