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 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 //$this->secret = $key; $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here /* function decode($N,$alphabet,$msg){ // Initialization $M = count($alphabet); $decrypt = array(); $decode = array(); $encrypted = preg_split("//",$msg, -1, PREG_SPLIT_NO_EMPTY); // Compute the decoding map $decode[' '] = ' '; foreach ($alphabet as $n=>$v){ $decode[$v] = $alphabet[($M+($n-$N)) % $M]; // Compute the decoding map for $v } foreach ($encrypted as $v){ $decrypt[] = $decode[$v]; } return join('',$decrypt); } $array = (array) $test; reset($array); $first_key = key($array); print_r($array[$first_key]); //used this to figure out the count: // http://rumkin.com/tools/cipher/caesar.php $key = decode(13,26, $array[$first_key]); */ function caesar($str, $n) { $ret = ""; for($i = 0, $l = strlen($str); $i < $l; ++$i) { $c = ord($str[$i]); if (97 <= $c && $c < 123) { $ret.= chr(($c + $n + 7) % 26 + 97); } else if(65 <= $c && $c < 91) { $ret.= chr(($c + $n + 13) % 26 + 65); } else { $ret.= $str[$i]; } } return $ret; } $array = (array) $test; reset($array); $first_key = key($array); print_r($array[$first_key]); $secret = caesar($array[$first_key],13); //print_r('the secret is:'.$secret); $test->__set($secret , $secret[$secret]['yum']); // 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.0110.00416.60
8.3.50.0080.00721.92
8.3.40.0040.01418.97
8.3.30.0100.00319.27
8.3.20.0040.00420.22
8.3.10.0030.00523.65
8.3.00.0040.00419.38
8.2.180.0120.00618.67
8.2.170.0170.00322.96
8.2.160.0100.00718.97
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0130.00726.16
8.2.120.0050.00222.07
8.2.110.0080.00022.33
8.2.100.0110.00017.97
8.2.90.0000.00819.33
8.2.80.0000.00818.16
8.2.70.0030.00617.75
8.2.60.0000.00818.04
8.2.50.0040.00418.07
8.2.40.0060.00319.95
8.2.30.0000.00718.14
8.2.20.0070.00017.84
8.2.10.0030.00518.25
8.2.00.0030.00717.89
8.1.280.0150.00025.92
8.1.270.0090.00023.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.84
8.1.230.0050.00519.14
8.1.220.0080.00017.76
8.1.210.0130.00318.77
8.1.200.0100.00017.35
8.1.190.0050.00317.53
8.1.180.0000.01119.01
8.1.170.0040.00418.64
8.1.160.0040.00422.16
8.1.150.0100.00018.63
8.1.140.0040.00417.45
8.1.130.0030.00317.86
8.1.120.0000.00717.52
8.1.110.0100.00017.42
8.1.100.0060.00317.55
8.1.90.0000.00717.38
8.1.80.0070.00017.39
8.1.70.0000.00717.44
8.1.60.0030.00617.60
8.1.50.0040.00417.54
8.1.40.0040.00417.46
8.1.30.0080.00017.67
8.1.20.0000.00817.71
8.1.10.0040.00417.46
8.1.00.0000.00817.38
8.0.300.0040.00419.21
8.0.290.0030.00617.05
8.0.280.0030.00418.44
8.0.270.0000.00717.17
8.0.260.0040.00417.34
8.0.250.0030.00316.99
8.0.240.0000.00717.00
8.0.230.0000.00716.96
8.0.220.0000.00717.00
8.0.210.0040.00417.00
8.0.200.0040.00416.96
8.0.190.0060.00317.07
8.0.180.0040.00416.91
8.0.170.0000.00817.06
8.0.160.0050.00316.98
8.0.150.0050.00217.02
8.0.140.0040.00416.96
8.0.130.0000.00613.41
8.0.120.0000.00816.96
8.0.110.0000.00717.05
8.0.100.0030.00517.05
8.0.90.0040.00417.02
8.0.80.0060.00916.90
8.0.70.0000.00817.01
8.0.60.0070.00016.98
8.0.50.0000.00716.88
8.0.30.0100.01217.20
8.0.20.0100.01017.40
8.0.10.0030.00517.09
8.0.00.0110.00716.88
7.4.330.0030.00515.00
7.4.320.0060.00016.52
7.4.300.0060.00016.54
7.4.290.0000.00716.55
7.4.280.0000.00716.65
7.4.270.0080.00016.56
7.4.260.0030.00316.60
7.4.250.0030.00616.50
7.4.240.0030.00316.58
7.4.230.0070.00016.70
7.4.220.0090.00916.57
7.4.210.0050.01016.63
7.4.200.0040.00316.47
7.4.190.0000.00716.75
7.4.160.0070.01016.62
7.4.150.0070.01117.40
7.4.140.0080.00817.86
7.4.130.0090.00916.54
7.4.120.0050.01216.52
7.4.110.0030.01416.44
7.4.100.0100.01016.55
7.4.90.0100.00716.55
7.4.80.0160.00319.39
7.4.70.0050.01416.51
7.4.60.0150.00916.48
7.4.50.0030.00516.39
7.4.40.0030.00922.77
7.4.30.0120.00916.47
7.4.00.0060.00614.81
7.3.330.0000.00613.49
7.3.320.0060.00013.24
7.3.310.0070.00016.50
7.3.300.0060.00316.34
7.3.290.0030.01216.50
7.3.280.0060.01016.44
7.3.270.0120.00617.40
7.3.260.0100.00716.50
7.3.250.0090.00916.48
7.3.240.0060.01016.48
7.3.230.0120.00616.45
7.3.210.0100.00616.45
7.3.200.0090.01419.39
7.3.190.0070.01316.53
7.3.180.0100.00516.52
7.3.170.0060.01016.50
7.3.160.0060.00916.68
7.3.120.0060.00614.81
7.2.330.0070.01016.42
7.2.320.0090.01516.57
7.2.310.0140.00716.80
7.2.300.0090.00916.87
7.2.290.0030.01516.80
7.2.80.0030.00716.52
7.2.60.0000.01416.68
7.2.00.0040.01219.63
7.1.200.0030.01015.91
7.1.100.0050.00517.94
7.1.70.0160.00616.75
7.1.60.0100.01419.46
7.1.50.0000.01316.95
7.1.00.0070.07322.43
7.0.200.0070.00016.93
7.0.140.0030.07322.02
7.0.60.0030.07019.93
7.0.50.0100.04317.91
7.0.40.0070.04020.20
7.0.30.0200.06020.27
7.0.20.0230.05720.05
7.0.10.0230.06320.09
7.0.00.0100.06320.33
5.6.280.0030.07321.16
5.6.210.0100.07020.54
5.6.200.0030.06718.16
5.6.190.0100.08020.61
5.6.180.0330.04720.48
5.6.170.0270.07320.51
5.6.160.0200.07720.76
5.6.150.0170.05318.23
5.6.140.0030.08018.28
5.6.130.0100.05018.28
5.6.120.0070.05321.15
5.6.110.0170.08021.04
5.6.100.0030.08021.01
5.6.90.0170.06721.00
5.6.80.0100.06720.54
5.5.350.0100.05320.45
5.5.340.0100.07717.95
5.5.330.0030.04020.29
5.5.320.0270.04720.34
5.5.310.0270.07020.51
5.5.300.0070.09318.04
5.5.290.0100.05317.93
5.5.280.0100.08020.99
5.5.270.0100.06320.77
5.5.260.0100.08020.88
5.5.250.0070.08020.71
5.5.240.0030.08320.13
5.4.450.0930.06319.67
5.4.440.0900.06019.46
5.4.430.0800.05719.52
5.4.420.0700.05319.54
5.4.410.0170.05019.20
5.4.400.0570.05319.14
5.4.390.0870.05319.27
5.4.380.0470.05018.61
5.4.370.0670.04718.84
5.4.360.0270.05718.81
5.4.350.0230.06318.58
5.4.340.0300.05318.63
5.4.320.0060.04212.51
5.4.310.0050.04912.51
5.4.300.0060.04812.52
5.4.290.0100.05912.50
5.4.280.0090.05212.40
5.4.270.0090.05812.39
5.4.260.0120.06612.40
5.4.250.0050.04712.39
5.4.240.0090.03912.39
5.4.230.0060.04712.39
5.4.220.0050.06012.39
5.4.210.0180.06812.38
5.4.200.0100.07512.39
5.4.190.0250.08912.38
5.4.180.0090.04212.38
5.4.170.0080.03912.39
5.4.160.0140.03512.39
5.4.150.0080.03812.38
5.4.140.0110.04112.07
5.4.130.0090.03712.05
5.4.120.0080.04112.02
5.4.110.0060.04112.01
5.4.100.0070.03912.01
5.4.90.0200.06312.01
5.4.80.0100.07112.01
5.4.70.0050.04512.00
5.4.60.0070.05312.00
5.4.50.0190.06112.00
5.4.40.0070.06111.98
5.4.30.0110.04411.98
5.4.20.0080.05111.98
5.4.10.0050.05311.99
5.4.00.0080.06911.48
5.3.290.0040.04112.80
5.3.280.0110.04212.71
5.3.270.0120.05112.73
5.3.260.0070.04112.72
5.3.250.0070.04012.72
5.3.240.0070.04112.72
5.3.230.0110.03812.70
5.3.220.0060.04112.68
5.3.210.0080.04412.68
5.3.200.0100.05412.68
5.3.190.0070.06912.67
5.3.180.0100.05312.68
5.3.170.0070.05612.67
5.3.160.0050.05612.67
5.3.150.0090.05212.67
5.3.140.0100.06612.66
5.3.130.0060.05612.66
5.3.120.0070.05812.66
5.3.110.0090.06112.66
5.3.100.0090.05412.13
5.3.90.0080.05912.11
5.3.80.0080.06012.11
5.3.70.0250.05212.11
5.3.60.0110.05112.09
5.3.50.0120.05712.04
5.3.40.0090.05012.04
5.3.30.0140.07812.00
5.3.20.0050.06711.78
5.3.10.0120.05711.74
5.3.00.0080.05411.73
5.2.170.0070.0349.23
5.2.160.0050.0329.23
5.2.150.0030.0359.23
5.2.140.0010.0389.23
5.2.130.0070.0309.19
5.2.120.0090.0269.19
5.2.110.0040.0339.20
5.2.100.0070.0309.20
5.2.90.0070.0309.19
5.2.80.0070.0389.19
5.2.70.0080.0489.19
5.2.60.0090.0679.14
5.2.50.0060.0369.11
5.2.40.0100.0269.08
5.2.30.0020.0359.06
5.2.20.0060.0339.05
5.2.10.0140.0368.95
5.2.00.0080.0588.82
5.1.60.0110.0378.10
5.1.50.0050.0388.10
5.1.40.0100.0338.08
5.1.30.0100.0428.43
5.1.20.0110.0408.45
5.1.10.0080.0278.18
5.1.00.0050.0448.18
5.0.50.0060.0336.66
5.0.40.0070.0396.52
5.0.30.0040.0456.34
5.0.20.0040.0206.30
5.0.10.0060.0276.28
5.0.00.0090.0456.27
4.4.90.0020.0474.78
4.4.80.0130.0334.76
4.4.70.0070.0264.75
4.4.60.0020.0314.75
4.4.50.0090.0344.77
4.4.40.0050.0374.70
4.4.30.0080.0294.76
4.4.20.0090.0474.84
4.4.10.0020.0244.84
4.4.00.0050.0374.76
4.3.110.0030.0254.66
4.3.100.0030.0324.66
4.3.90.0070.0234.64
4.3.80.0090.0354.58
4.3.70.0040.0194.63
4.3.60.0030.0254.63
4.3.50.0040.0244.63
4.3.40.0060.0314.54
4.3.30.0070.0463.30
4.3.20.0070.0353.28
4.3.10.0020.0373.23
4.3.00.0270.01710.54

preferences:
35.78 ms | 401 KiB | 5 Q