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 echo $key;exit; $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here class MyClass implements arrayaccess{ protected $array = array( 'arraykey' => 'arraykey2', 'arraykey2' => 'callback', ); public $closure; 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 = $this->closure->bindTo($test); // I dont really understand what this is doing } public function __toString(){ // Object of class V could not be converted to string; return 'arraykey'; } // 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.40.0040.01118.96
8.3.30.0070.00719.16
8.3.20.0040.00420.20
8.3.10.0080.00022.27
8.3.00.0050.00322.34
8.2.170.0040.01122.96
8.2.160.0090.00620.34
8.2.150.0090.00024.18
8.2.140.0090.00024.66
8.2.130.0050.00226.16
8.2.120.0000.00819.48
8.2.110.0030.00722.27
8.2.100.0070.00419.57
8.2.90.0000.00819.36
8.2.80.0080.00018.04
8.2.70.0030.00517.75
8.2.60.0100.00018.03
8.2.50.0000.00818.07
8.2.40.0080.00018.22
8.2.30.0030.00718.01
8.2.20.0000.00717.88
8.2.10.0000.00819.70
8.2.00.0040.00417.69
8.1.270.0000.00922.05
8.1.260.0040.00426.35
8.1.250.0000.00928.09
8.1.240.0060.00323.74
8.1.230.0060.00619.17
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0090.00017.35
8.1.190.0000.01117.55
8.1.180.0080.00018.10
8.1.170.0030.00518.64
8.1.160.0040.00421.93
8.1.150.0040.00418.65
8.1.140.0070.00017.46
8.1.130.0040.00417.77
8.1.120.0000.00717.37
8.1.110.0040.00417.43
8.1.100.0000.00717.40
8.1.90.0080.00217.41
8.1.80.0070.00017.45
8.1.70.0040.00417.49
8.1.60.0090.00017.63
8.1.50.0040.00417.44
8.1.40.0040.00417.58
8.1.30.0060.00317.66
8.1.20.0040.00417.69
8.1.10.0000.00717.58
8.1.00.0000.00817.46
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0050.00218.41
8.0.270.0000.00817.26
8.0.260.0000.00716.88
8.0.250.0030.00316.90
8.0.240.0060.00316.93
8.0.230.0040.00416.93
8.0.220.0030.00316.90
8.0.210.0000.00716.94
8.0.200.0060.00016.85
8.0.190.0040.00417.04
8.0.180.0040.00416.91
8.0.170.0030.00516.95
8.0.160.0000.00717.04
8.0.150.0050.00216.95
8.0.140.0000.00816.91
8.0.130.0050.00013.36
8.0.120.0080.00016.89
8.0.110.0000.00816.92
8.0.100.0040.00416.77
8.0.90.0070.00016.94
8.0.80.0090.00617.00
8.0.70.0000.00816.95
8.0.60.0000.00816.83
8.0.50.0040.00416.95
8.0.30.0070.01417.03
8.0.20.0130.00717.40
8.0.10.0070.00016.91
8.0.00.0070.01416.93
7.4.330.0070.00015.00
7.4.320.0000.00616.53
7.4.300.0060.00016.41
7.4.290.0000.00716.61
7.4.280.0030.00516.61
7.4.270.0070.00016.63
7.4.260.0080.00016.40
7.4.250.0000.00716.54
7.4.240.0020.00516.52
7.4.230.0030.00316.50
7.4.220.0090.00916.63
7.4.210.0070.00916.49
7.4.200.0030.00316.32
7.4.190.0070.00016.46
7.4.160.0110.00416.57
7.4.150.0070.01117.40
7.4.140.0090.01517.86
7.4.130.0100.00716.55
7.4.120.0070.01016.57
7.4.110.0100.00716.61
7.4.100.0140.00416.75
7.4.90.0160.00016.61
7.4.80.0000.02019.39
7.4.70.0100.00616.52
7.4.60.0090.00616.68
7.4.50.0060.00316.54
7.4.40.0000.01822.77
7.4.30.0090.00616.57
7.4.00.0000.01315.22
7.3.330.0050.00013.30
7.3.320.0000.00613.39
7.3.310.0070.00016.54
7.3.300.0020.00516.31
7.3.290.0060.01316.29
7.3.280.0050.01016.39
7.3.270.0140.00317.40
7.3.260.0150.00416.52
7.3.250.0100.00716.58
7.3.240.0140.00716.45
7.3.230.0030.01316.68
7.3.210.0110.00816.50
7.3.200.0040.01219.39
7.3.190.0130.00616.64
7.3.180.0090.00616.60
7.3.170.0090.01316.43
7.3.160.0160.00016.32
7.3.120.0130.00314.58
7.2.330.0070.01016.80
7.2.320.0110.00916.75
7.2.310.0100.00616.64
7.2.300.0100.00716.61
7.2.290.0070.01016.92
7.2.00.0040.01119.28
7.1.100.0060.00618.30
7.1.70.0000.01216.86
7.1.60.0000.01419.82
7.1.50.0110.01416.96
7.1.00.0100.07322.44
7.0.200.0100.00316.80
7.0.140.0000.07322.00
7.0.60.0070.08719.99
7.0.50.0070.04017.89
7.0.40.0100.04020.24
7.0.30.0370.06720.06
7.0.20.0400.07320.20
7.0.10.0300.08020.33
7.0.00.0100.04020.23
5.6.280.0100.06721.11
5.6.210.0130.07020.52
5.6.200.0070.03718.25
5.6.190.0000.04720.53
5.6.180.3500.04020.48
5.6.170.0230.04720.51
5.6.160.0100.05720.52
5.6.150.0070.07018.18
5.6.140.0070.06718.29
5.6.130.0130.07318.26
5.6.120.0070.04721.14
5.6.110.0000.04720.89
5.6.100.0200.07321.04
5.6.90.0030.04021.12
5.6.80.0100.07320.43
5.6.70.0300.03020.41
5.5.350.0030.03020.48
5.5.340.0070.03717.94
5.5.330.0030.08320.47
5.5.320.0200.04720.52
5.5.310.0330.07020.28
5.5.300.0070.08718.04
5.5.290.0000.06717.98
5.5.280.0070.08720.86
5.5.270.0100.04020.69
5.5.260.0200.08020.68
5.5.250.0030.04320.56
5.5.240.0070.03320.16
5.4.450.0170.05019.13
5.4.440.0600.06719.56
5.4.430.0170.06319.43
5.4.420.0100.07719.54
5.4.410.0200.06319.31
5.4.400.0970.00018.73
5.4.390.1000.00018.75
5.4.380.0230.05318.62
5.4.370.0130.05018.85
5.4.360.0130.05018.77
5.4.350.0100.05718.64
5.4.340.0270.04018.71
5.4.320.0090.03412.52
5.4.310.0070.03612.52
5.4.300.0070.04412.52
5.4.290.0070.03812.51
5.4.280.0060.03712.41
5.4.270.0130.05318.94
5.4.260.0170.07018.96
5.4.250.0130.05318.96
5.4.240.0130.06018.93
5.4.230.0030.06018.89
5.4.220.0200.04318.75
5.4.210.0230.05018.79
5.4.200.0070.06718.83
5.4.190.0070.07318.95
5.4.180.0130.06018.83
5.4.170.0070.08018.79
5.4.160.0170.04718.73
5.4.150.0100.08018.76
5.4.140.0070.06316.45
5.4.130.0070.07016.60
5.4.120.0100.06716.50
5.4.110.0130.05716.59
5.4.100.0100.07016.44
5.4.90.0030.05716.62
5.4.80.0200.04716.46
5.4.70.0200.05716.44
5.4.60.0070.05016.63
5.4.50.0130.05016.49
5.4.40.0200.05016.65
5.4.30.0170.07016.30
5.4.20.0130.04716.62
5.4.10.0100.06716.47
5.4.00.0070.05716.08
5.3.290.0090.04312.80
5.3.280.0070.05714.79
5.3.270.0030.06014.53
5.3.260.0170.05714.76
5.3.250.0070.05314.61
5.3.240.0130.05014.61
5.3.230.0100.04714.45
5.3.220.0100.07714.56
5.3.210.0130.05314.74
5.3.200.0170.04014.77
5.3.190.0230.05314.57
5.3.180.0070.04714.55
5.3.170.0030.07714.72
5.3.160.0100.05014.76
5.3.150.0030.07714.66
5.3.140.0130.07014.59
5.3.130.0130.07314.55
5.3.120.0100.05314.73
5.3.110.0130.07014.79
5.3.100.0100.05314.22
5.3.90.0130.06714.03
5.3.80.0100.07014.21
5.3.70.0100.06014.07
5.3.60.0130.05714.09
5.3.50.0030.06313.80
5.3.40.0070.05714.04
5.3.30.0100.05714.10
5.3.20.0170.05713.82
5.3.10.0130.05013.50
5.3.00.0070.05313.82
5.2.170.0100.05711.14
5.2.160.0070.04011.22
5.2.150.0070.04311.38
5.2.140.0000.06311.14
5.2.130.0130.03711.07
5.2.120.0170.03311.18
5.2.110.0030.05711.02
5.2.100.0070.05311.20
5.2.90.0130.04711.18
5.2.80.0070.06011.18
5.2.70.0070.04011.26
5.2.60.0100.05711.29
5.2.50.0070.04011.11
5.2.40.0130.04011.17
5.2.30.0100.04010.96
5.2.20.0100.05311.19
5.2.10.0100.04010.70
5.2.00.0070.04010.82
5.1.60.0100.04010.21
5.1.50.0030.03310.02
5.1.40.0070.0439.99
5.1.30.0070.04010.18
5.1.20.0000.05710.27
5.1.10.0100.03710.13
5.1.00.0100.04010.06
5.0.50.0130.0378.52
5.0.40.0100.0208.43
5.0.30.0000.0638.24
5.0.20.0100.0208.36
5.0.10.0070.0338.25
5.0.00.0030.0478.13
4.4.90.0100.0236.20
4.4.80.0030.0236.20
4.4.70.0000.0236.20
4.4.60.0000.0336.20
4.4.50.0000.0336.20
4.4.40.0000.0376.20
4.4.30.0100.0176.20
4.4.20.0030.0206.20
4.4.10.0000.0276.20
4.4.00.0030.0376.19
4.3.110.0030.0236.19
4.3.100.0030.0236.19
4.3.90.0000.0236.19
4.3.80.0000.0476.19
4.3.70.0000.0276.19
4.3.60.0100.0176.19
4.3.50.0100.0236.19
4.3.40.0070.0306.19
4.3.30.0000.0306.19
4.3.20.0000.0306.19
4.3.10.0000.0276.19
4.3.00.0000.0276.54

preferences:
30.52 ms | 400 KiB | 5 Q