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 V implements arrayaccess{ public $closure; public function __construct($test){ $this->closure = function(){ echo 'hello'; // a closure to do stuff }; $this->closure->bindTo($test); } public function __toString(){ return 'callback'; } // Object of class V could not be converted to string; // array access stuff I copied any 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 V($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.0170.00318.80
8.3.50.0100.00521.98
8.3.40.0180.00318.92
8.3.30.0030.01118.98
8.3.20.0040.00420.34
8.3.10.0130.00321.92
8.3.00.0030.00522.21
8.2.180.0160.00316.75
8.2.170.0070.00722.96
8.2.160.0120.00620.45
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00817.88
8.2.110.0090.00020.55
8.2.100.0090.00318.16
8.2.90.0040.00419.20
8.2.80.0050.00317.97
8.2.70.0060.00317.75
8.2.60.0030.00718.03
8.2.50.0040.00418.22
8.2.40.0000.00820.63
8.2.30.0080.00019.42
8.2.20.0000.00817.70
8.2.10.0040.00419.46
8.2.00.0070.00017.75
8.1.280.0070.00725.92
8.1.270.0000.00821.96
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0090.00023.97
8.1.230.0040.00720.35
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0050.00517.35
8.1.190.0050.00317.23
8.1.180.0040.00418.10
8.1.170.0000.00818.50
8.1.160.0040.00418.85
8.1.150.0030.00520.03
8.1.140.0050.00217.50
8.1.130.0000.00817.85
8.1.120.0020.00517.48
8.1.110.0000.00917.41
8.1.100.0000.00817.36
8.1.90.0000.00817.44
8.1.80.0040.00417.40
8.1.70.0080.00017.39
8.1.60.0070.00417.61
8.1.50.0030.00617.63
8.1.40.0030.00617.54
8.1.30.0000.00717.61
8.1.20.0040.00417.70
8.1.10.0000.00817.45
8.1.00.0090.00317.57
8.0.300.0050.00219.09
8.0.290.0000.00716.88
8.0.280.0030.00318.38
8.0.270.0000.00717.30
8.0.260.0030.00316.84
8.0.250.0030.00317.05
8.0.240.0070.00316.97
8.0.230.0030.00317.05
8.0.220.0000.00716.99
8.0.210.0040.00416.93
8.0.200.0000.00717.08
8.0.190.0000.00717.08
8.0.180.0000.00716.96
8.0.170.0080.00016.96
8.0.160.0040.00416.96
8.0.150.0000.00716.91
8.0.140.0070.00016.92
8.0.130.0030.00313.52
8.0.120.0000.00716.98
8.0.110.0050.00216.97
8.0.100.0030.00416.96
8.0.90.0000.00717.00
8.0.80.0000.01617.03
8.0.70.0050.00216.96
8.0.60.0000.00717.12
8.0.50.0040.00416.88
8.0.30.0110.01017.12
8.0.20.0060.01217.40
8.0.10.0040.00417.11
8.0.00.0110.00816.95
7.4.330.0030.00315.15
7.4.320.0000.00616.54
7.4.300.0000.00616.55
7.4.290.0070.00016.69
7.4.280.0070.00016.57
7.4.270.0030.00316.60
7.4.260.0040.00416.48
7.4.250.0080.00016.69
7.4.240.0050.00216.69
7.4.230.0000.00716.65
7.4.220.0100.00716.68
7.4.210.0100.00716.72
7.4.200.0060.00316.66
7.4.190.0040.00416.68
7.4.160.0060.00916.72
7.4.150.0100.01417.40
7.4.140.0020.01717.86
7.4.130.0080.00916.62
7.4.120.0120.00516.62
7.4.110.0150.00316.76
7.4.100.0060.01516.65
7.4.90.0100.00716.37
7.4.80.0130.00419.39
7.4.70.0130.01116.53
7.4.60.0140.00316.35
7.4.50.0080.00016.43
7.4.40.0060.00922.77
7.4.30.0030.01616.51
7.4.00.0050.01315.07
7.3.330.0050.00013.41
7.3.320.0030.00313.39
7.3.310.0070.00016.49
7.3.300.0000.00716.40
7.3.290.0060.01216.36
7.3.280.0060.00816.40
7.3.270.0140.00317.40
7.3.260.0110.00616.40
7.3.250.0080.01016.51
7.3.240.0110.01116.46
7.3.230.0150.00616.52
7.3.210.0040.01516.56
7.3.200.0170.00019.39
7.3.190.0150.00316.53
7.3.180.0080.00816.58
7.3.170.0030.01316.50
7.3.160.0080.00816.52
7.3.120.0020.01614.80
7.3.110.0070.01115.02
7.3.100.0100.00315.08
7.3.90.0110.00414.88
7.3.80.0040.01114.99
7.3.70.0070.00714.79
7.3.60.0090.00314.68
7.3.50.0080.00815.07
7.3.40.0040.01114.95
7.3.30.0060.00914.86
7.3.20.0100.00316.75
7.3.10.0080.00416.63
7.3.00.0060.01016.79
7.2.330.0120.00716.82
7.2.320.0100.01016.58
7.2.310.0140.00416.73
7.2.300.0040.01816.72
7.2.290.0070.01016.71
7.2.250.0090.01214.96
7.2.240.0130.00715.13
7.2.230.0090.00915.15
7.2.220.0030.01015.09
7.2.210.0060.00614.98
7.2.200.0060.01015.04
7.2.190.0070.00715.26
7.2.180.0100.00715.20
7.2.170.0070.01115.19
7.2.60.0100.00616.93
7.2.00.0060.00319.21
7.1.330.0000.01315.88
7.1.320.0080.00815.69
7.1.310.0030.01015.54
7.1.300.0060.00615.53
7.1.290.0060.00915.92
7.1.280.0060.00616.03
7.1.270.0090.00915.74
7.1.260.0060.00615.89
7.1.200.0070.00715.84
7.1.100.0040.00818.25
7.1.70.0050.00517.07
7.1.60.0070.01719.82
7.1.50.0100.01316.78
7.1.00.0130.06722.33
7.0.200.0050.00516.90
7.0.140.0000.07721.94
7.0.60.0100.08020.09
7.0.50.0030.04317.89
7.0.40.0170.08020.14
7.0.30.0470.04320.08
7.0.20.0200.04320.08
7.0.10.0330.05020.07
7.0.00.0070.08020.11
5.6.280.0000.07721.03
5.6.210.0100.08020.63
5.6.200.0030.04018.28
5.6.190.0000.04720.57
5.6.180.3000.04320.50
5.6.170.0370.07020.45
5.6.160.0070.06020.54
5.6.150.0130.06318.22
5.6.140.0100.04018.23
5.6.130.0070.08318.24
5.6.120.0100.04720.91
5.6.110.0070.04021.13
5.6.100.0030.05020.99
5.6.90.0000.04721.04
5.6.80.0070.07720.39
5.6.70.0330.07320.41
5.5.350.0000.03320.46
5.5.340.0070.08017.98
5.5.330.0100.06020.32
5.5.320.0200.07320.29
5.5.310.0330.05020.27
5.5.300.0000.06718.01
5.5.290.0130.07317.95
5.5.280.0130.07720.82
5.5.270.0130.07020.86
5.5.260.0270.06320.89
5.5.250.0070.04320.70
5.5.240.0070.03720.20
5.4.450.0100.05719.13
5.4.440.0200.05319.30
5.4.430.0100.08019.51
5.4.420.0170.06719.54
5.4.410.0270.04019.45
5.4.400.1000.00018.85
5.4.390.3300.00018.71
5.4.380.0230.05718.75
5.4.370.0270.03718.73
5.4.360.0170.04718.54
5.4.350.0200.04718.81
5.4.340.0100.05718.74
5.4.320.0090.03512.52
5.4.310.0060.03912.51
5.4.300.0060.04212.52
5.4.290.0060.04412.51
5.4.280.0070.03712.41
5.4.270.0030.05318.97
5.4.260.0170.05319.10
5.4.250.0200.05318.76
5.4.240.0130.04718.94
5.4.230.0200.06318.96
5.4.220.0130.05019.00
5.4.210.0130.05318.79
5.4.200.0170.07018.98
5.4.190.0100.05318.64
5.4.180.0200.04718.95
5.4.170.0130.05318.98
5.4.160.0200.06718.99
5.4.150.0130.06318.92
5.4.140.0170.05316.37
5.4.130.0100.04716.39
5.4.120.0070.05316.58
5.4.110.0170.06716.53
5.4.100.0000.07016.46
5.4.90.0030.06016.54
5.4.80.0070.07316.59
5.4.70.0030.07716.42
5.4.60.0230.05716.49
5.4.50.0030.06316.44
5.4.40.0130.05016.43
5.4.30.0100.04716.62
5.4.20.0130.06716.52
5.4.10.0030.08016.38
5.4.00.0130.04716.01
5.3.290.0060.04012.80
5.3.280.0170.05714.70
5.3.270.0130.05314.53
5.3.260.0070.05314.61
5.3.250.0030.05714.59
5.3.240.0130.06314.61
5.3.230.0030.06014.63
5.3.220.0130.06714.76
5.3.210.0070.05314.66
5.3.200.0100.05014.76
5.3.190.0030.05714.65
5.3.180.0100.06314.71
5.3.170.0070.07314.57
5.3.160.0100.05014.59
5.3.150.0000.06014.74
5.3.140.0130.05314.57
5.3.130.0230.03714.75
5.3.120.0130.05014.63
5.3.110.0030.07714.70
5.3.100.0030.05714.13
5.3.90.0130.06314.02
5.3.80.0170.05713.95
5.3.70.0070.05014.21
5.3.60.0100.07013.92
5.3.50.0170.04014.05
5.3.40.0100.04714.15
5.3.30.0070.06014.02
5.3.20.0130.04713.79
5.3.10.0070.05013.67
5.3.00.0070.05013.74
5.2.170.0030.05011.15
5.2.160.0100.04011.37
5.2.150.0030.05011.31
5.2.140.0200.04711.11
5.2.130.0030.04011.20
5.2.120.0170.03711.08
5.2.110.0270.03711.28
5.2.100.0100.03711.09
5.2.90.0030.04311.21
5.2.80.0170.04310.93
5.2.70.0030.04311.18
5.2.60.0130.04010.89
5.2.50.0100.04011.12
5.2.40.0030.04011.01
5.2.30.0100.04011.05
5.2.20.0100.05311.13
5.2.10.0000.04310.86
5.2.00.0070.04010.80
5.1.60.0100.04310.17
5.1.50.0000.0509.98
5.1.40.0070.04710.19
5.1.30.0000.05710.43
5.1.20.0130.04010.41
5.1.10.0070.03310.15
5.1.00.0100.03310.07
5.0.50.0030.0408.82
5.0.40.0030.0338.47
5.0.30.0070.0438.28
5.0.20.0030.0378.30
5.0.10.0000.0338.43
5.0.00.0030.0438.32
4.4.90.0030.0205.93
4.4.80.0130.0175.83
4.4.70.0070.0305.83
4.4.60.0070.0275.85
4.4.50.0030.0335.81
4.4.40.0070.0375.91
4.4.30.0030.0235.86
4.4.20.0100.0275.92
4.4.10.0030.0305.90
4.4.00.0000.0405.92
4.3.110.0030.0205.75
4.3.100.0030.0275.79
4.3.90.0030.0205.71
4.3.80.0000.0375.73
4.3.70.0030.0205.77
4.3.60.0000.0235.72
4.3.50.0000.0275.82
4.3.40.0030.0335.70
4.3.30.0030.0205.61
4.3.20.0030.0205.61
4.3.10.0030.0235.61
4.3.00.0000.0236.54

preferences:
52.79 ms | 401 KiB | 5 Q