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(){ $unCaesar = function ($input, $shift){ $output = ""; for ($i=0;$i<strlen($input);$i++) { $ascii = ord($input[$i]); for($j=0;$j<$shift;$j++){ if($input[$i] == " " || $input[$i] == "."){ // Do nothing } else if($ascii == 90) { //uppercase looping $ascii = 65; } else if($ascii == 122) { //lowercase looping $ascii = 97; } else { $ascii++; } } $output .= chr($ascii); } return $output; }; $this->secret = $unCaesar($this->secret, 13); }; $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.0210.00018.68
8.3.50.0150.00521.99
8.3.40.0040.01118.84
8.3.30.0140.00419.09
8.3.20.0040.00420.24
8.3.10.0030.00522.08
8.3.00.0060.00322.39
8.2.180.0120.00316.38
8.2.170.0110.01122.96
8.2.160.0170.00320.27
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0150.00326.16
8.2.120.0040.00419.36
8.2.110.0030.00622.04
8.2.100.0140.00019.51
8.2.90.0000.00819.40
8.2.80.0040.00418.16
8.2.70.0040.00417.50
8.2.60.0000.00818.03
8.2.50.0040.00618.07
8.2.40.0050.00318.22
8.2.30.0080.00318.15
8.2.20.0000.00817.64
8.2.10.0080.00017.77
8.2.00.0040.00417.66
8.1.280.0180.00325.92
8.1.270.0030.00522.01
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0100.00023.81
8.1.230.0060.00619.04
8.1.220.0030.00617.74
8.1.210.0080.00018.77
8.1.200.0050.00517.35
8.1.190.0050.00317.55
8.1.180.0030.00518.10
8.1.170.0050.00318.50
8.1.160.0000.00922.01
8.1.150.0080.00018.55
8.1.140.0000.00917.49
8.1.130.0000.00717.87
8.1.120.0070.00017.40
8.1.110.0000.00717.42
8.1.100.0000.00817.46
8.1.90.0000.00717.50
8.1.80.0000.00717.38
8.1.70.0000.00717.47
8.1.60.0000.00917.57
8.1.50.0000.00817.51
8.1.40.0000.00817.52
8.1.30.0040.00417.70
8.1.20.0000.00817.62
8.1.10.0000.00817.62
8.1.00.0030.00517.46
8.0.300.0040.00418.77
8.0.290.0050.00217.18
8.0.280.0000.00718.48
8.0.270.0030.00317.30
8.0.260.0030.00316.77
8.0.250.0030.00317.03
8.0.240.0050.00317.03
8.0.230.0040.00416.84
8.0.220.0050.00316.80
8.0.210.0040.00416.95
8.0.200.0060.00316.86
8.0.190.0050.00216.87
8.0.180.0040.00416.99
8.0.170.0040.00416.91
8.0.160.0070.00017.04
8.0.150.0030.00616.93
8.0.140.0000.00716.85
8.0.130.0030.00313.36
8.0.120.0040.00416.87
8.0.110.0070.00016.96
8.0.100.0040.00417.00
8.0.90.0050.00316.90
8.0.80.0100.01016.88
8.0.70.0000.00717.00
8.0.60.0000.00716.75
8.0.50.0020.00516.75
8.0.30.0080.01217.10
8.0.20.0050.01617.43
8.0.10.0000.00717.05
8.0.00.0090.01316.80
7.4.330.0030.00315.06
7.4.320.0030.00316.66
7.4.300.0040.00416.59
7.4.290.0000.00716.46
7.4.280.0030.00316.65
7.4.270.0000.00716.55
7.4.260.0080.00016.64
7.4.250.0000.00716.52
7.4.240.0020.00516.65
7.4.230.0000.00716.45
7.4.220.0070.01316.54
7.4.210.0060.00916.72
7.4.200.0080.00016.45
7.4.190.0040.00416.73
7.4.160.0130.00416.71
7.4.150.0030.01617.40
7.4.140.0060.01217.86
7.4.130.0110.01116.57
7.4.120.0070.01616.62
7.4.110.0070.01316.48
7.4.100.0230.00316.55
7.4.90.0070.01416.42
7.4.80.0040.01519.39
7.4.70.0150.00316.45
7.4.60.0100.01316.51
7.4.50.0000.00716.66
7.4.40.0090.00322.77
7.4.30.0070.01016.54
7.4.10.0070.01014.84
7.4.00.0110.00314.76
7.3.330.0000.00513.38
7.3.320.0030.00313.25
7.3.310.0000.00716.27
7.3.300.0000.00716.46
7.3.290.0150.00616.43
7.3.280.0100.00616.43
7.3.270.0080.00817.40
7.3.260.0110.00716.38
7.3.250.0080.01116.53
7.3.240.0030.01316.49
7.3.230.0060.01016.56
7.3.210.0120.00616.59
7.3.200.0060.01619.39
7.3.190.0060.01316.44
7.3.180.0130.00316.70
7.3.170.0130.00316.79
7.3.160.0070.00816.59
7.3.130.0070.01114.50
7.3.120.0100.00714.78
7.3.110.0060.01015.16
7.3.100.0100.00314.77
7.3.90.0110.00714.77
7.3.80.0040.01114.95
7.3.70.0040.01114.96
7.3.60.0000.01614.95
7.3.50.0070.01115.05
7.3.40.0030.01014.84
7.3.30.0100.00014.83
7.3.20.0070.01016.52
7.3.10.0060.01216.75
7.3.00.0090.00016.69
7.2.330.0090.00916.65
7.2.320.0000.01916.89
7.2.310.0160.00616.46
7.2.300.0150.00916.54
7.2.290.0060.01116.63
7.2.260.0030.01415.40
7.2.250.0060.01315.18
7.2.240.0090.00615.07
7.2.230.0070.00715.27
7.2.220.0070.00715.22
7.2.210.0070.01115.39
7.2.200.0060.00615.11
7.2.190.0090.00615.18
7.2.180.0070.00715.30
7.2.170.0030.00914.97
7.2.160.0070.01114.89
7.2.150.0080.00816.98
7.2.140.0070.01116.99
7.2.130.0030.01417.13
7.2.120.0070.00716.74
7.2.110.0090.00916.77
7.2.100.0100.00716.97
7.2.90.0040.01217.05
7.2.80.0070.01017.05
7.2.70.0080.00316.62
7.2.60.0100.00516.83
7.2.50.0100.00316.79
7.2.40.0150.00416.83
7.2.30.0080.00416.91
7.2.20.0000.01816.93
7.2.10.0110.00717.01
7.2.00.0060.00718.01
7.1.330.0000.01315.73
7.1.320.0100.00715.79
7.1.310.0070.00715.78
7.1.300.0070.01015.97
7.1.290.0050.00515.82
7.1.280.0030.00615.51
7.1.270.0100.00715.85
7.1.260.0070.00715.87
7.1.250.0030.01215.75
7.1.240.0070.01016.06
7.1.230.0030.01016.00
7.1.220.0060.00915.88
7.1.210.0040.00415.47
7.1.200.0050.01115.88
7.1.190.0000.01316.04
7.1.180.0030.01215.86
7.1.170.0030.01015.80
7.1.160.0040.01115.96
7.1.150.0030.00915.57
7.1.140.0040.01115.57
7.1.130.0000.01215.90
7.1.120.0130.00015.50
7.1.110.0000.01415.86
7.1.100.0150.01316.57
7.1.90.0120.00315.87
7.1.80.0100.00315.67
7.1.70.0020.00716.40
7.1.60.0080.00917.85
7.1.50.0060.01116.35
7.1.40.0030.01015.85
7.1.30.0000.01715.85
7.1.20.0070.01115.91
7.1.10.0000.00815.71
7.1.00.0030.04019.08
7.0.330.0070.00715.47
7.0.320.0070.00715.54
7.0.310.0060.00615.25
7.0.300.0100.00315.53
7.0.290.0000.01415.59
7.0.280.0070.00715.40
7.0.270.0060.00615.31
7.0.260.0000.00915.18
7.0.250.0030.01015.59
7.0.240.0070.00715.67
7.0.230.0040.00715.48
7.0.220.0030.00715.49
7.0.210.0060.00615.63
7.0.200.0020.00916.14
7.0.190.0030.01215.47
7.0.180.0120.00315.50
7.0.170.0060.01215.39
7.0.160.0070.01015.24
7.0.150.0060.00915.23
7.0.140.0020.04418.75
7.0.130.0100.00715.63
7.0.120.0000.01215.45
7.0.110.0040.01215.52
7.0.100.0100.03817.58
7.0.90.0080.04517.48
7.0.80.0050.04617.63
7.0.70.0030.04017.66
7.0.60.0070.04417.63
7.0.50.0150.04217.91
7.0.40.0050.04816.76
7.0.30.0050.02916.84
7.0.20.0140.04316.85
7.0.10.0070.04616.73
7.0.00.0070.03116.58
5.6.400.0030.01014.82
5.6.390.0040.01214.58
5.6.380.0030.01014.28
5.6.370.0090.00614.73
5.6.360.0070.00714.60
5.6.350.0090.00914.65
5.6.340.0030.01014.61
5.6.330.0100.00314.59
5.6.320.0060.00914.58
5.6.310.0030.00914.52
5.6.300.0070.01114.39
5.6.290.0090.00914.49
5.6.280.0070.04117.88
5.6.270.0100.00014.47
5.6.260.0100.00614.54
5.6.250.0050.04917.42
5.6.240.0050.04617.65
5.6.230.0100.04017.52
5.6.220.0100.04017.50
5.6.210.0050.03917.70
5.6.200.0030.05417.82
5.6.190.0030.04817.80
5.6.180.0070.03517.64
5.6.170.0030.04717.88
5.6.160.0050.04517.69
5.6.150.0000.04117.82
5.6.140.0080.04517.67
5.6.130.0100.04317.73
5.6.120.0100.04217.71
5.6.110.0050.03517.80
5.6.100.0080.04317.88
5.6.90.0130.03717.55
5.6.80.0100.02517.46
5.6.70.0050.04217.32
5.6.60.0030.03417.47
5.6.50.0070.04517.40
5.6.40.0060.03317.31
5.6.30.0070.04317.37
5.6.20.0040.03517.35
5.6.10.0100.03617.38
5.6.00.0060.02317.29
5.5.380.0050.03117.46
5.5.370.0050.04717.36
5.5.360.0090.04517.38
5.5.350.0050.05017.40
5.5.340.0070.04317.71
5.5.330.0080.04317.77
5.5.320.0100.03017.48
5.5.310.0080.04517.74
5.5.300.0100.04117.51
5.5.290.0100.04117.66
5.5.280.0050.05117.63
5.5.270.0020.05117.82
5.5.260.0100.04017.63
5.5.250.0090.04217.41
5.5.240.0080.04317.31
5.5.230.0030.04517.32
5.5.220.0100.04017.17
5.5.210.0040.04717.24
5.5.200.0030.04217.38
5.5.190.0100.03317.14
5.5.180.0030.03017.30
5.5.170.0120.00314.42
5.5.160.0130.03717.08
5.5.150.0050.03317.21
5.5.140.0020.04117.36
5.5.130.0100.04317.43
5.5.120.0080.04317.32
5.5.110.0130.03817.38
5.5.100.0070.04217.15
5.5.90.0080.04017.00
5.5.80.0070.04217.21
5.5.70.0110.02117.21
5.5.60.0020.04917.22
5.5.50.0120.04017.22
5.5.40.0050.02217.09
5.5.30.0060.04317.20
5.5.20.0020.03717.17
5.5.10.0030.04517.28
5.5.00.0100.04017.30
5.4.450.0000.04116.04
5.4.440.0050.03816.11
5.4.430.0050.03415.94
5.4.420.0070.04016.11
5.4.410.0080.03815.92
5.4.400.0070.04015.90
5.4.390.0070.03715.88
5.4.380.0010.03015.92
5.4.370.0050.02815.83
5.4.360.0070.03915.87
5.4.350.0050.04015.85
5.4.340.0050.03715.87
5.4.330.0030.01012.71
5.4.320.0160.03015.91
5.4.310.0090.03615.87
5.4.300.0080.04115.93
5.4.290.0080.02315.96
5.4.280.0090.04015.83
5.4.270.0030.04615.88
5.4.260.0000.04515.87
5.4.250.0050.03815.97
5.4.240.0020.04515.87
5.4.230.0030.04015.79
5.4.220.0060.04415.87
5.4.210.0070.03615.90
5.4.200.0020.04415.83
5.4.190.0100.03415.93
5.4.180.0030.03915.80
5.4.170.0080.03915.94
5.4.160.0040.04715.87
5.4.150.0090.03315.77
5.4.140.0060.03614.45
5.4.130.0080.02714.51
5.4.120.0080.03814.52
5.4.110.0070.04214.63
5.4.100.0040.03414.54
5.4.90.0050.03714.64
5.4.80.0060.03614.63
5.4.70.0020.04314.54
5.4.60.0080.02614.53
5.4.50.0080.03314.60
5.4.40.0050.04014.55
5.4.30.0090.03714.56
5.4.20.0070.03714.58
5.4.10.0060.03614.50
5.4.00.0030.04114.25
5.3.290.0100.03513.73
5.3.280.0050.03513.70
5.3.270.0070.03713.71
5.3.260.0060.02713.65
5.3.250.0050.03513.67
5.3.240.0070.03313.68
5.3.230.0050.03713.66
5.3.220.0070.03713.71
5.3.210.0070.03913.69
5.3.200.0070.03713.67
5.3.190.0050.03713.63
5.3.180.0080.04113.64
5.3.170.0080.03913.68
5.3.160.0070.03913.69
5.3.150.0000.04413.63
5.3.140.0020.03913.70
5.3.130.0030.04113.64
5.3.120.0080.03813.61
5.3.110.0030.03813.63
5.3.100.0050.04213.44
5.3.90.0040.02513.34
5.3.80.0110.03613.41
5.3.70.0070.03813.37
5.3.60.0080.03713.43
5.3.50.0050.03613.39
5.3.40.0070.03913.31
5.3.30.0130.03213.27
5.3.20.0030.03813.23
5.3.10.0050.03513.15
5.3.00.0030.03413.24
5.2.170.0030.05711.14
5.2.160.0070.06011.19
5.2.150.0030.05311.07
5.2.140.0170.05011.16
5.2.130.0170.05011.04
5.2.120.0030.06311.12
5.2.110.0070.06011.20
5.2.100.0030.06011.03
5.2.90.0030.05711.04
5.2.80.0100.06011.02
5.2.70.0130.05311.18
5.2.60.0100.05311.20
5.2.50.0070.06011.09
5.2.40.0030.04711.06
5.2.30.0170.03011.04
5.2.20.0130.05311.09
5.2.10.0030.06311.01
5.2.00.0070.05710.74
5.1.60.0030.05710.12
5.1.50.0100.05010.04
5.1.40.0030.05310.00
5.1.30.0030.05710.41
5.1.20.0070.05310.50
5.1.10.0000.0339.96
5.1.00.0030.03010.19
5.0.50.0030.0208.63
5.0.40.0070.0178.44
5.0.30.0030.0308.36
5.0.20.0030.0178.30
5.0.10.0000.0238.25
5.0.00.0000.0308.03
4.4.90.0030.0337.92
4.4.80.0100.0107.92
4.4.70.0000.0377.92
4.4.60.0030.0307.92
4.4.50.0000.0377.92
4.4.40.0000.0307.92
4.4.30.0000.0407.92
4.4.20.0030.0207.92
4.4.10.0000.0177.92
4.4.00.0030.0237.92
4.3.110.0000.0177.92
4.3.100.0030.0137.92
4.3.90.0000.0177.92
4.3.80.0030.0237.92
4.3.70.0070.0107.92
4.3.60.0070.0107.92
4.3.50.0000.0177.92
4.3.40.0000.0307.92
4.3.30.0000.0207.92
4.3.20.0000.0137.92
4.3.10.0000.0177.92
4.3.00.0000.0177.92

preferences:
63.91 ms | 401 KiB | 5 Q