3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 1: Modify Test::$secret before it's output. Rules:: 1. No use of Reflection API / runkit extension 2. No stopping execution before Test::run() 3. No Exceptions or PHP errors / warnings notices allowed 4. No redefining $test Hints: 1. Caesar 2. Magic methods 3. Requires a new feature of PHP 5.4 */ 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 editing here Class V implements arrayaccess{ protected $array = array( 'arraykey' => 'arraykey2', 'arraykey2' => 'callback', ); public $closure; function __construct($test) { $this->closure = function(){ $this->secret = str_rot13($this->secret); }; $this->closure = $this->closure->bindTo($test, $test); } function __invoke() { return $this->closure; } function __toString() { return "arraykey"; } 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; } } $v = new V($test); $test->callback = $v; // 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.0150.00018.40
8.3.50.0120.00522.05
8.3.40.0040.01118.84
8.3.30.0110.00319.13
8.3.20.0040.00420.16
8.3.10.0040.00421.88
8.3.00.0060.00322.18
8.2.180.0040.01118.54
8.2.170.0120.00322.96
8.2.160.0130.00020.39
8.2.150.0000.00724.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0080.00019.36
8.2.110.0070.00321.09
8.2.100.0080.00417.91
8.2.90.0000.00819.30
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0060.00317.79
8.2.50.0000.00818.07
8.2.40.0030.00518.16
8.2.30.0040.00418.07
8.2.20.0050.00217.64
8.2.10.0000.00817.68
8.2.00.0060.00317.76
8.1.280.0070.01025.92
8.1.270.0060.00922.23
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00621.45
8.1.230.0090.00317.64
8.1.220.0000.00817.79
8.1.210.0050.00518.77
8.1.200.0070.00317.23
8.1.190.0060.00317.35
8.1.180.0030.00518.10
8.1.170.0050.00318.65
8.1.160.0080.00022.03
8.1.150.0000.00718.54
8.1.140.0070.00017.45
8.1.130.0000.00717.52
8.1.120.0000.00717.55
8.1.110.0040.00417.47
8.1.100.0040.00417.47
8.1.90.0050.00317.45
8.1.80.0020.00517.46
8.1.70.0030.00317.48
8.1.60.0040.00517.48
8.1.50.0030.00617.59
8.1.40.0090.00017.41
8.1.30.0060.00317.73
8.1.20.0000.00817.60
8.1.10.0080.00017.48
8.1.00.0000.00717.49
8.0.300.0060.00318.77
8.0.290.0060.00316.63
8.0.280.0030.00318.40
8.0.270.0070.00017.28
8.0.260.0070.00016.80
8.0.250.0000.00716.95
8.0.240.0040.00416.85
8.0.230.0070.00017.00
8.0.220.0000.00716.89
8.0.210.0070.00016.89
8.0.200.0030.00617.02
8.0.190.0070.00016.87
8.0.180.0050.00316.95
8.0.170.0000.00716.89
8.0.160.0040.00416.93
8.0.150.0000.00716.86
8.0.140.0000.00716.88
8.0.130.0000.00813.27
8.0.120.0000.00716.77
8.0.110.0040.00416.86
8.0.100.0040.00416.91
8.0.90.0070.00016.86
8.0.80.0050.01016.96
8.0.70.0050.00316.95
8.0.60.0040.00416.73
8.0.50.0040.00416.80
8.0.30.0120.00916.92
8.0.20.0100.00917.40
8.0.10.0040.00417.03
8.0.00.0060.01216.92
7.4.330.0000.00615.08
7.4.320.0030.00316.61
7.4.300.0000.00616.50
7.4.290.0050.00316.60
7.4.280.0000.00716.60
7.4.270.0080.00016.52
7.4.260.0000.00716.60
7.4.250.0080.00016.50
7.4.240.0030.00516.53
7.4.230.0000.00716.57
7.4.220.0090.00916.73
7.4.210.0120.00316.56
7.4.200.0000.00816.64
7.4.190.0050.00216.66
7.4.160.0110.00516.44
7.4.150.0090.00917.40
7.4.140.0140.00817.86
7.4.130.0110.00716.54
7.4.120.0090.00916.46
7.4.110.0070.01016.57
7.4.100.0130.01016.61
7.4.90.0130.00916.40
7.4.80.0090.00919.39
7.4.70.0150.00416.56
7.4.60.0070.01716.64
7.4.50.0040.00416.63
7.4.40.0100.00722.77
7.4.30.0110.01116.57
7.4.00.0070.01114.83
7.3.330.0000.00513.39
7.3.320.0000.00513.39
7.3.310.0070.00016.40
7.3.300.0020.00516.44
7.3.290.0030.01116.36
7.3.280.0080.01016.38
7.3.270.0070.01017.40
7.3.260.0070.01416.34
7.3.250.0060.01116.52
7.3.240.0150.00416.42
7.3.230.0040.01516.39
7.3.210.0180.00016.39
7.3.200.0060.01119.39
7.3.190.0100.00716.41
7.3.180.0090.00916.20
7.3.170.0130.00316.52
7.3.160.0110.00516.40
7.3.120.0070.01015.00
7.2.330.0110.00716.70
7.2.320.0070.01316.55
7.2.310.0140.01016.78
7.2.300.0130.01016.86
7.2.290.0060.01216.45
7.2.60.0040.01116.73
7.2.00.0080.00819.68
7.1.200.0070.00415.95
7.1.100.0300.00817.78
7.1.70.0000.01317.00
7.1.60.0150.00919.82
7.1.50.0090.01516.97
7.1.00.0100.07022.42
7.0.200.0090.00016.88
7.0.140.0100.06722.09
7.0.60.0030.05719.89
7.0.50.0030.06017.88
7.0.40.0000.06320.13
7.0.30.0400.04020.06
7.0.20.0230.05720.03
7.0.10.0100.04020.09
7.0.00.0100.08720.24
5.6.280.0100.08020.80
5.6.210.0100.04320.49
5.6.200.0130.05318.15
5.6.190.0100.03720.65
5.6.180.0300.08020.47
5.6.170.0230.05320.70
5.6.160.0100.08020.50
5.6.150.0030.07718.16
5.6.140.0100.04718.25
5.6.130.0130.08318.13
5.6.120.0000.05021.04
5.6.110.0070.07721.17
5.6.100.0030.07320.98
5.6.90.0000.04721.02
5.6.80.0030.05320.40
5.5.350.0370.08020.43
5.5.340.0100.07318.02
5.5.330.0070.04720.27
5.5.320.0370.07320.27
5.5.310.0270.07020.30
5.5.300.0170.06317.94
5.5.290.0070.07718.02
5.5.280.0100.04020.89
5.5.270.0100.08320.89
5.5.260.0100.04320.78
5.5.250.0070.06020.57
5.5.240.2170.03020.28
5.4.450.0000.04719.47
5.4.440.0570.04019.30
5.4.430.0900.04719.27
5.4.420.0570.04019.57
5.4.410.0370.02719.41
5.4.400.0400.04019.07
5.4.390.0330.04318.98
5.4.380.0400.05018.78
5.4.370.0530.05018.63
5.4.360.0370.05018.73
5.4.350.0430.04318.46
5.4.340.0400.04718.74
5.4.320.0070.03512.52
5.4.310.0100.04812.52
5.4.300.0070.04412.52
5.4.290.0100.04012.51
5.4.280.0040.03812.41
5.4.270.0070.05718.94
5.4.260.0130.05018.75
5.4.250.0070.05318.73
5.4.240.0230.04318.74
5.4.230.0170.07018.85
5.4.220.0230.06018.65
5.4.210.0100.06318.89
5.4.200.0070.05318.65
5.4.190.0070.05318.74
5.4.180.0100.06018.83
5.4.170.0200.04019.00
5.4.160.0130.06318.63
5.4.150.0070.05318.82
5.4.140.0030.05716.42
5.4.130.0100.05716.50
5.4.120.0100.05016.48
5.4.110.0100.07316.55
5.4.100.0070.05716.44
5.4.90.0100.06716.54
5.4.80.0130.05316.61
5.4.70.0100.05316.52
5.4.60.0170.06016.50
5.4.50.0070.05016.48
5.4.40.0070.05016.51
5.4.30.0100.04716.48
5.4.20.0030.05716.47
5.4.10.0170.04716.54
5.4.00.0200.05716.04
5.3.290.0040.04212.80
5.3.280.0100.05714.75
5.3.270.0100.06014.62
5.3.260.0170.07314.84
5.3.250.0070.07014.71
5.3.240.0130.04714.45
5.3.230.0130.06314.68
5.3.220.0170.05714.65
5.3.210.0030.05714.64
5.3.200.0170.04714.67
5.3.190.0070.05314.57
5.3.180.0070.06714.80
5.3.170.0100.05714.57
5.3.160.0130.05314.75
5.3.150.0070.07314.48
5.3.140.0100.05014.65
5.3.130.0000.06314.55
5.3.120.0170.06714.59
5.3.110.0130.06714.55
5.3.100.0030.05314.12
5.3.90.0000.05714.12
5.3.80.0100.06713.87
5.3.70.0200.04014.26
5.3.60.0130.05713.99
5.3.50.0200.04013.99
5.3.40.0170.06013.99
5.3.30.0130.07013.90
5.3.20.0070.05313.82
5.3.10.0200.04313.57
5.3.00.0070.05313.66
5.2.170.0070.06011.24
5.2.160.0170.03311.24
5.2.150.0030.04311.24
5.2.140.0100.04011.22
5.2.130.0000.04711.11
5.2.120.0030.06011.30
5.2.110.0130.03311.18
5.2.100.0070.04011.09
5.2.90.0130.04711.20
5.2.80.0100.03711.16
5.2.70.0030.05011.19
5.2.60.0130.05311.22
5.2.50.0170.03010.94
5.2.40.0070.04711.07
5.2.30.0030.04310.96
5.2.20.0070.05310.93
5.2.10.0030.04710.95
5.2.00.0130.03310.90
5.1.60.0030.0409.85
5.1.50.0030.04710.08
5.1.40.0030.05010.00
5.1.30.0170.04010.50
5.1.20.0030.04010.45
5.1.10.0100.03310.17
5.1.00.0100.04710.32
5.0.50.0070.0438.63
5.0.40.0030.0338.49
5.0.30.0030.0538.19
5.0.20.0100.0338.05
5.0.10.0070.0308.25
5.0.00.0030.0578.18
4.4.90.0070.0206.52
4.4.80.0030.0306.51
4.4.70.0030.0236.43
4.4.60.0030.0276.43
4.4.50.0030.0306.43
4.4.40.0030.0306.43
4.4.30.0000.0336.43
4.4.20.0100.0206.43
4.4.10.0130.0206.43
4.4.00.0000.0406.43
4.3.110.0030.0306.43
4.3.100.0030.0306.43
4.3.90.0000.0236.43
4.3.80.0030.0306.43
4.3.70.0100.0206.43
4.3.60.0030.0206.43
4.3.50.0030.0206.43
4.3.40.0100.0376.43
4.3.30.0000.0306.43
4.3.20.0030.0206.43
4.3.10.0030.0276.43
4.3.00.0030.01713.50

preferences:
42.87 ms | 401 KiB | 5 Q