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 '1'; } // 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.40.0140.00318.84
8.3.30.0110.00419.04
8.3.20.0070.00020.39
8.3.10.0000.00821.87
8.3.00.0040.00422.52
8.2.170.0120.00922.96
8.2.160.0120.00320.53
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00317.75
8.2.110.0180.00420.52
8.2.100.0090.00318.03
8.2.90.0040.00419.32
8.2.80.0030.00618.04
8.2.70.0000.00817.75
8.2.60.0040.00418.05
8.2.50.0060.00318.07
8.2.40.0030.00517.90
8.2.30.0040.00418.20
8.2.20.0040.00417.85
8.2.10.0000.00919.59
8.2.00.0000.00717.83
8.1.270.0070.00023.99
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0090.01223.91
8.1.230.0080.00423.88
8.1.220.0040.00717.79
8.1.210.0000.00918.77
8.1.200.0090.00017.48
8.1.190.0040.00417.41
8.1.180.0060.00318.10
8.1.170.0080.00018.71
8.1.160.0020.00522.14
8.1.150.0080.00018.63
8.1.140.0030.00617.46
8.1.130.0040.00417.88
8.1.120.0000.00817.50
8.1.110.0000.00717.42
8.1.100.0000.00717.44
8.1.90.0040.00417.47
8.1.80.0050.00317.55
8.1.70.0030.00317.52
8.1.60.0000.00817.49
8.1.50.0040.00417.48
8.1.40.0050.00317.54
8.1.30.0040.00417.57
8.1.20.0000.00817.68
8.1.10.0000.00817.59
8.1.00.0030.00517.55
8.0.300.0000.00818.77
8.0.290.0000.00717.12
8.0.280.0000.00818.44
8.0.270.0030.00317.32
8.0.260.0000.00716.82
8.0.250.0000.00817.09
8.0.240.0070.00016.92
8.0.230.0070.00017.03
8.0.220.0000.00716.98
8.0.210.0030.00316.87
8.0.200.0080.00016.97
8.0.190.0000.00917.05
8.0.180.0040.00416.90
8.0.170.0050.00316.91
8.0.160.0040.00416.96
8.0.150.0030.00316.82
8.0.140.0030.00616.93
8.0.130.0030.00313.42
8.0.120.0030.00516.93
8.0.110.0000.00716.89
8.0.100.0040.00416.78
8.0.90.0040.00417.04
8.0.80.0040.01217.01
8.0.70.0040.00417.04
8.0.60.0000.00716.86
8.0.50.0040.00416.86
8.0.30.0130.01117.23
8.0.20.0100.00817.40
8.0.10.0070.00017.12
8.0.00.0110.00816.92
7.4.330.0070.00015.00
7.4.320.0060.00016.52
7.4.300.0070.00016.65
7.4.290.0030.00316.43
7.4.280.0000.00716.61
7.4.270.0000.00716.63
7.4.260.0000.00716.46
7.4.250.0040.00416.51
7.4.240.0000.00716.53
7.4.230.0040.00416.33
7.4.220.0120.00616.53
7.4.210.0080.00716.65
7.4.200.0040.00416.71
7.4.190.0070.00016.50
7.4.160.0090.00616.69
7.4.150.0070.01017.40
7.4.140.0110.00817.86
7.4.130.0120.00916.66
7.4.120.0080.00916.64
7.4.110.0100.00616.71
7.4.100.0120.00616.62
7.4.90.0090.00916.45
7.4.80.0000.01819.39
7.4.70.0110.01516.36
7.4.60.0070.01016.58
7.4.50.0060.00316.46
7.4.40.0050.00522.77
7.4.30.0100.00716.59
7.4.10.0060.01314.89
7.4.00.0070.01015.22
7.3.330.0020.00213.43
7.3.320.0050.00013.40
7.3.310.0040.00416.49
7.3.300.0030.00316.34
7.3.290.0040.01116.39
7.3.280.0050.01016.40
7.3.270.0100.00717.40
7.3.260.0100.00716.59
7.3.250.0090.00816.43
7.3.240.0000.01816.30
7.3.230.0100.00716.51
7.3.210.0140.00816.38
7.3.200.0130.00319.39
7.3.190.0060.01016.52
7.3.180.0120.00316.45
7.3.170.0070.01116.50
7.3.160.0100.01316.45
7.3.130.0110.00414.95
7.3.120.0100.00714.95
7.3.110.0030.01714.83
7.3.100.0080.00414.82
7.3.90.0070.00714.89
7.3.80.0160.00014.76
7.3.70.0040.01114.78
7.3.60.0060.00614.95
7.3.50.0110.00414.43
7.3.40.0040.00814.73
7.3.30.0030.01014.86
7.3.20.0060.00916.36
7.3.10.0040.00816.71
7.3.00.0060.00616.54
7.2.330.0000.01916.63
7.2.320.0170.00716.85
7.2.310.0130.00316.68
7.2.300.0120.00916.77
7.2.290.0060.01116.72
7.2.260.0070.01115.06
7.2.250.0030.01414.90
7.2.240.0040.01214.89
7.2.230.0150.00015.06
7.2.220.0040.01115.27
7.2.210.0000.01515.22
7.2.200.0060.00915.11
7.2.190.0030.00815.02
7.2.180.0130.00015.07
7.2.170.0030.00914.84
7.2.160.0030.01014.88
7.2.150.0080.00316.69
7.2.140.0000.00916.95
7.2.130.0090.00317.13
7.2.120.0110.00316.78
7.2.110.0100.00716.82
7.2.100.0080.00417.02
7.2.90.0040.00817.16
7.2.80.0070.01117.07
7.2.70.0060.00617.12
7.2.60.0070.00716.75
7.2.50.0000.01316.66
7.2.40.0130.00016.92
7.2.30.0110.00317.00
7.2.20.0040.00817.02
7.2.10.0130.00316.79
7.2.00.0050.00818.08
7.1.330.0000.01315.79
7.1.320.0030.00915.94
7.1.310.0060.00315.71
7.1.300.0030.00615.71
7.1.290.0080.00415.79
7.1.280.0070.00715.78
7.1.270.0110.00415.59
7.1.260.0060.00615.66
7.1.250.0120.00315.82
7.1.240.0000.01215.75
7.1.230.0030.00615.77
7.1.220.0070.00315.63
7.1.210.0070.00715.82
7.1.200.0070.00815.81
7.1.190.0060.00915.75
7.1.180.0080.00415.86
7.1.170.0030.00615.64
7.1.160.0030.01415.76
7.1.150.0060.00915.49
7.1.140.0060.00615.82
7.1.130.0070.00715.75
7.1.120.0040.00415.79
7.1.110.0080.00615.96
7.1.100.0060.00516.88
7.1.90.0030.00915.71
7.1.80.0070.00315.74
7.1.70.0000.01116.36
7.1.60.0030.01017.84
7.1.50.0070.01116.36
7.1.40.0060.00615.71
7.1.30.0090.00615.89
7.1.20.0000.01315.86
7.1.10.0050.00515.90
7.1.00.0050.04219.13
7.0.330.0030.00915.34
7.0.320.0070.00715.34
7.0.310.0070.00415.54
7.0.300.0030.01015.09
7.0.290.0000.01015.30
7.0.280.0030.00915.55
7.0.270.0090.00015.42
7.0.260.0000.01215.21
7.0.250.0060.00615.61
7.0.240.0040.00815.33
7.0.230.0060.00615.44
7.0.220.0000.01715.30
7.0.210.0030.01015.24
7.0.200.0080.00516.15
7.0.190.0060.00615.45
7.0.180.0030.00915.14
7.0.170.0030.01015.46
7.0.160.0040.01115.43
7.0.150.0060.00615.47
7.0.140.0030.04218.69
7.0.130.0130.00015.07
7.0.120.0110.00415.35
7.0.110.0040.01215.43
7.0.100.0030.00715.50
7.0.90.0040.00715.32
7.0.80.0070.01015.51
7.0.70.0000.01415.43
7.0.60.0070.04418.61
7.0.50.0070.02116.67
7.0.40.0100.04516.89
7.0.30.0180.04516.84
7.0.20.0130.03616.79
7.0.10.0050.05016.95
7.0.00.0070.02516.93
5.6.400.0070.00714.18
5.6.390.0030.00914.41
5.6.380.0030.01014.57
5.6.370.0090.00614.19
5.6.360.0040.00414.54
5.6.350.0070.00714.39
5.6.340.0070.00714.33
5.6.330.0060.00614.44
5.6.320.0090.00614.56
5.6.310.0050.00514.56
5.6.300.0000.01214.58
5.6.290.0000.01514.25
5.6.280.0070.03817.63
5.6.270.0000.01314.60
5.6.260.0000.01114.42
5.6.250.0060.00914.48
5.6.240.0070.00714.67
5.6.230.0030.01014.68
5.6.220.0030.00914.52
5.6.210.0070.03017.70
5.6.200.0070.03816.25
5.6.190.0000.04517.47
5.6.180.0170.03017.59
5.6.170.0200.04217.62
5.6.160.0050.04717.41
5.6.150.0040.02616.20
5.6.140.0090.04016.21
5.6.130.0120.03816.34
5.6.120.0120.04217.60
5.6.110.0090.04617.84
5.6.100.0100.03517.66
5.6.90.0080.02617.68
5.6.80.0100.03317.57
5.6.70.0060.00914.38
5.6.60.0030.00914.38
5.6.50.0030.00714.21
5.6.40.0080.00314.20
5.6.30.0070.00714.36
5.6.20.0120.00314.23
5.6.10.0000.01114.55
5.6.00.0060.00614.32
5.5.380.0030.00714.52
5.5.370.0080.00014.66
5.5.360.0150.00014.32
5.5.350.1970.02317.30
5.5.340.0080.02316.28
5.5.330.0030.02717.33
5.5.320.0320.03717.50
5.5.310.0220.02217.38
5.5.300.0080.04116.20
5.5.290.0050.02616.23
5.5.280.0020.02917.65
5.5.270.0080.04217.53
5.5.260.0050.04217.79
5.5.250.0090.03517.40
5.5.240.0030.02917.31
5.5.230.0060.00614.30
5.5.220.0040.01114.27
5.5.210.0040.00414.16
5.5.200.0090.00914.17
5.5.190.0000.01314.22
5.5.180.0030.00614.48
5.5.170.0000.01614.12
5.5.160.0030.00714.64
5.5.150.0000.01414.32
5.5.140.0030.01014.26
5.5.130.0040.00714.25
5.5.120.0100.00013.92
5.5.110.0000.00814.32
5.5.100.0070.01014.27
5.5.90.0100.00714.23
5.5.80.0060.00514.43
5.5.70.0030.00614.56
5.5.60.0060.00814.52
5.5.50.0040.01114.46
5.5.40.0030.01014.39
5.5.30.0060.00614.48
5.5.20.0090.00314.54
5.5.10.0030.01014.58
5.5.00.0070.01014.18
5.4.450.2030.02315.18
5.4.440.2050.01915.15
5.4.430.1900.01815.23
5.4.420.1870.02515.38
5.4.410.1880.02115.26
5.4.400.1580.02715.13
5.4.390.2030.02015.01
5.4.380.2010.02315.15
5.4.370.1980.02215.10
5.4.360.2030.02015.19
5.4.350.1550.02015.11
5.4.340.1180.03014.96
5.4.330.0070.00711.14
5.4.320.1820.02015.21
5.4.310.1830.02514.85
5.4.300.1520.01814.98
5.4.290.1200.01714.91
5.4.280.1750.02215.20
5.4.270.2280.02015.02
5.4.260.2000.02214.95
5.4.250.1870.02615.14
5.4.240.1740.01914.98
5.4.230.2120.01515.01
5.4.220.1980.02515.10
5.4.210.1710.02415.16
5.4.200.2030.02015.04
5.4.190.1690.02014.96
5.4.180.1880.02315.09
5.4.170.1880.02215.08
5.4.160.2000.02015.16
5.4.150.1990.02115.09
5.4.140.1970.02313.85
5.4.130.2000.02113.77
5.4.120.2000.02113.83
5.4.110.2000.02013.79
5.4.100.2000.02013.88
5.4.90.2000.02213.85
5.4.80.2000.02113.75
5.4.70.2000.02213.59
5.4.60.2060.01813.81
5.4.50.1900.02313.52
5.4.40.1880.02313.70
5.4.30.2470.02113.82
5.4.20.1790.01813.73
5.4.10.1950.02113.86
5.4.00.1970.02513.56
5.3.290.1850.02612.70
5.3.280.2090.02412.64
5.3.270.1450.02212.61
5.3.260.2020.02012.69
5.3.250.1860.02212.67
5.3.240.2030.02312.68
5.3.230.2010.02012.68
5.3.220.1870.02412.60
5.3.210.2160.02612.43
5.3.200.2070.01712.49
5.3.190.1980.02012.49
5.3.180.1950.02412.68
5.3.170.2010.02112.63
5.3.160.1940.02012.66
5.3.150.2150.02912.66
5.3.140.1900.02212.62
5.3.130.1920.02012.62
5.3.120.1870.02012.53
5.3.110.1940.02112.63
5.3.100.1960.02212.26
5.3.90.1960.01712.42
5.3.80.2200.02012.29
5.3.70.1620.01912.10
5.3.60.2200.02512.24
5.3.50.1980.01812.23
5.3.40.2110.01512.37
5.3.30.2080.02112.24
5.3.20.1900.02012.21
5.3.10.1950.02312.02
5.3.00.2380.01812.03
5.2.170.3500.02011.19
5.2.160.3530.02711.19
5.2.150.3470.02311.15
5.2.140.3430.02711.16
5.2.130.3270.02711.16
5.2.120.3370.03011.11
5.2.110.3800.02711.11
5.2.100.3570.03311.26
5.2.90.4000.02311.04
5.2.80.4030.02711.14
5.2.70.3200.02311.05
5.2.60.3970.02711.20
5.2.50.3730.02711.08
5.2.40.3430.02011.14
5.2.30.2970.03010.97
5.2.20.3000.02710.88
5.2.10.2930.02310.89
5.2.00.3200.03010.80
5.1.60.3070.02310.02
5.1.50.1870.01710.07
5.1.40.0000.05710.14
5.1.30.0070.05310.41
5.1.20.0030.03310.36
5.1.10.0930.03310.09
5.1.00.3230.02710.13
5.0.50.1700.0238.70
5.0.40.1570.0138.39
5.0.30.1570.0378.24
5.0.20.1500.0208.20
5.0.10.1500.0238.18
5.0.00.1570.0308.15
4.4.90.1500.0135.96
4.4.80.1800.0175.96
4.4.70.1530.0135.96
4.4.60.1830.0175.96
4.4.50.1700.0175.96
4.4.40.1800.0275.96
4.4.30.0000.0175.96
4.4.20.0030.0335.98
4.4.10.1900.0175.96
4.4.00.1500.0275.96
4.3.110.1630.0175.96
4.3.100.1270.0105.96
4.3.90.1600.0105.96
4.3.80.1500.0235.96
4.3.70.1730.0135.96
4.3.60.1600.0135.96
4.3.50.1230.0175.96
4.3.40.1770.0275.96
4.3.30.0830.0205.96
4.3.20.0970.0205.96
4.3.10.0770.0105.96
4.3.00.0870.0235.96

preferences:
43.52 ms | 400 KiB | 5 Q