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 $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['yummy'])]); // 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.00716.63
8.3.50.0070.01222.10
8.3.40.0140.00418.72
8.3.30.0060.00919.04
8.3.20.0050.00320.29
8.3.10.0030.00523.48
8.3.00.0060.00319.51
8.2.180.0050.01018.66
8.2.170.0070.00722.96
8.2.160.0170.00320.44
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0100.00726.16
8.2.120.0040.00422.25
8.2.110.0070.00322.28
8.2.100.0060.00617.78
8.2.90.0000.00819.23
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0050.00317.93
8.2.50.0090.00018.07
8.2.40.0090.00020.01
8.2.30.0000.00818.15
8.2.20.0040.00417.80
8.2.10.0000.00818.18
8.2.00.0080.00017.84
8.1.280.0170.00025.92
8.1.270.0000.00823.98
8.1.260.0030.00626.35
8.1.250.0080.00028.09
8.1.240.0000.00823.91
8.1.230.0110.00019.16
8.1.220.0000.00917.74
8.1.210.0000.00818.77
8.1.200.0000.01017.35
8.1.190.0000.00817.53
8.1.180.0030.00619.01
8.1.170.0060.00318.64
8.1.160.0000.00822.05
8.1.150.0060.00318.72
8.1.140.0040.00417.41
8.1.130.0030.00317.86
8.1.120.0000.00717.43
8.1.110.0040.00717.57
8.1.100.0050.00217.34
8.1.90.0070.00017.50
8.1.80.0000.00717.50
8.1.70.0070.00017.46
8.1.60.0030.00617.59
8.1.50.0000.00817.39
8.1.40.0040.00417.61
8.1.30.0050.00517.64
8.1.20.0060.00317.72
8.1.10.0060.00317.64
8.1.00.0030.00517.56
8.0.300.0040.00420.83
8.0.290.0050.00317.30
8.0.280.0000.00718.54
8.0.270.0070.00017.29
8.0.260.0030.00317.30
8.0.250.0000.00717.05
8.0.240.0000.00716.96
8.0.230.0000.00717.06
8.0.220.0070.00016.92
8.0.210.0000.00616.89
8.0.200.0030.00317.07
8.0.190.0000.00917.02
8.0.180.0070.00017.02
8.0.170.0000.00716.94
8.0.160.0000.00716.90
8.0.150.0080.00016.98
8.0.140.0000.00816.89
8.0.130.0030.00313.39
8.0.120.0000.00716.96
8.0.110.0040.00416.98
8.0.100.0050.00217.02
8.0.90.0040.00416.86
8.0.80.0060.00917.00
8.0.70.0040.00416.95
8.0.60.0070.00016.88
8.0.50.0040.00417.04
8.0.30.0100.00917.23
8.0.20.0090.01017.47
8.0.10.0070.00017.01
8.0.00.0140.00316.81
7.4.330.0030.00315.00
7.4.320.0000.00716.64
7.4.300.0030.00316.55
7.4.290.0070.00016.69
7.4.280.0030.00316.64
7.4.270.0000.00716.45
7.4.260.0030.00316.55
7.4.250.0040.00416.44
7.4.240.0030.00516.64
7.4.230.0070.00016.67
7.4.220.0100.01016.72
7.4.210.0080.00816.63
7.4.200.0080.00016.47
7.4.190.0040.00416.71
7.4.160.0130.00716.57
7.4.150.0100.00617.40
7.4.140.0050.01717.86
7.4.130.0100.00716.63
7.4.120.0100.00816.57
7.4.110.0060.01116.55
7.4.100.0140.00516.45
7.4.90.0110.00616.55
7.4.80.0070.01719.39
7.4.70.0120.01216.71
7.4.60.0080.00816.62
7.4.50.0030.00616.71
7.4.40.0070.00722.77
7.4.30.0080.00816.54
7.4.00.0110.00514.93
7.3.330.0060.00013.34
7.3.320.0060.00013.48
7.3.310.0040.00416.53
7.3.300.0060.00316.41
7.3.290.0100.01016.42
7.3.280.0090.00916.45
7.3.270.0160.00917.40
7.3.260.0060.01316.57
7.3.250.0060.01016.61
7.3.240.0130.00316.64
7.3.230.0090.00916.44
7.3.210.0110.00916.46
7.3.200.0110.01419.39
7.3.190.0100.00616.46
7.3.180.0120.00316.75
7.3.170.0040.01116.52
7.3.160.0130.00916.42
7.3.120.0060.01114.81
7.3.110.0030.00714.99
7.3.100.0060.00614.75
7.3.90.0070.01114.91
7.3.80.0110.00614.72
7.3.70.0110.00714.57
7.3.60.0060.00614.64
7.3.50.0030.00914.80
7.3.40.0090.00914.64
7.3.30.0030.00714.70
7.3.20.0070.00416.43
7.3.10.0070.00716.73
7.3.00.0000.01216.75
7.2.330.0170.00316.82
7.2.320.0040.01516.77
7.2.310.0110.00616.51
7.2.300.0130.00716.73
7.2.290.0120.00416.84
7.2.250.0030.01414.90
7.2.240.0050.01214.96
7.2.230.0000.01915.14
7.2.220.0070.01115.12
7.2.210.0070.00715.34
7.2.200.0030.01015.04
7.2.190.0080.00814.88
7.2.180.0070.00714.90
7.2.170.0090.00614.98
7.2.60.0140.01116.25
7.1.330.0070.00715.68
7.1.320.0030.00615.91
7.1.310.0100.00615.77
7.1.300.0000.01015.85
7.1.290.0070.00715.86
7.1.280.0110.00615.89
7.1.270.0030.01015.55
7.1.260.0040.01115.81
7.1.200.0090.00315.78
7.1.100.0040.01117.90
7.1.70.0040.00416.96
7.1.60.0150.01119.46
7.1.50.0090.01316.67
7.1.00.0070.07322.49
7.0.200.0000.00716.78
7.0.140.0100.06721.96
7.0.60.0070.07319.93
7.0.50.0030.06017.74
7.0.40.0000.04720.13
7.0.30.0170.04020.08
7.0.20.0300.08020.08
7.0.10.0000.05720.15
7.0.00.0030.04320.12
5.6.280.0100.06721.11
5.6.210.0070.03720.70
5.6.200.0100.04318.28
5.6.190.0030.09020.77
5.6.180.0270.06020.58
5.6.170.0300.07020.51
5.6.160.0100.04720.39
5.6.150.0070.04718.21
5.6.140.0130.07318.18
5.6.130.0100.05018.18
5.6.120.0070.05021.01
5.6.110.0200.07321.02
5.6.100.0100.08720.90
5.6.90.0130.08321.02
5.6.80.0130.07320.54
5.6.70.1470.03320.59
5.5.350.0200.03320.32
5.5.340.0030.03718.10
5.5.330.0100.08320.57
5.5.320.0270.08020.34
5.5.310.0230.04720.28
5.5.300.0030.08717.94
5.5.290.0130.07717.95
5.5.280.0030.04320.88
5.5.270.0070.08020.74
5.5.260.0070.09320.88
5.5.250.0130.07720.63
5.5.240.4070.03320.17
5.4.450.0800.06719.16
5.4.440.0530.05719.43
5.4.430.0870.05019.36
5.4.420.0330.06319.46
5.4.410.0700.06719.35
5.4.400.0870.07019.26
5.4.390.0800.05719.22
5.4.380.0330.05718.76
5.4.370.0300.04718.82
5.4.360.0230.05318.62
5.4.350.0370.05318.80
5.4.340.0330.06018.52
5.4.320.0070.04112.52
5.4.310.0080.04412.51
5.4.300.0110.04412.51
5.4.290.0080.05412.50
5.4.280.0150.05312.39
5.4.270.0140.06012.40
5.4.260.0100.05612.40
5.4.250.0080.05412.39
5.4.240.0050.05512.39
5.4.230.0070.05512.39
5.4.220.0080.05412.39
5.4.210.0080.05212.39
5.4.200.0080.05512.39
5.4.190.0130.05012.38
5.4.180.0070.05012.38
5.4.170.0070.05812.39
5.4.160.0090.04712.39
5.4.150.0100.04712.38
5.4.140.0080.04612.07
5.4.130.0060.04112.05
5.4.120.0090.03412.01
5.4.110.0070.03612.01
5.4.100.0110.04412.01
5.4.90.0110.04812.01
5.4.80.0130.05312.01
5.4.70.0060.05112.01
5.4.60.0060.04312.01
5.4.50.0050.03712.00
5.4.40.0070.03911.99
5.4.30.0080.03811.99
5.4.20.0060.03911.99
5.4.10.0100.03811.98
5.4.00.0090.04311.48
5.3.290.0100.04112.80
5.3.280.0070.04812.71
5.3.270.0110.05212.72
5.3.260.0080.05512.72
5.3.250.0100.03712.72
5.3.240.0060.04112.72
5.3.230.0060.04212.71
5.3.220.0040.04412.68
5.3.210.0090.04112.68
5.3.200.0050.04612.68
5.3.190.0070.04712.68
5.3.180.0060.03712.67
5.3.170.0060.04112.67
5.3.160.0060.04012.67
5.3.150.0090.03812.67
5.3.140.0110.04012.66
5.3.130.0110.04512.66
5.3.120.0100.03912.66
5.3.110.0150.08212.66
5.3.100.0090.04612.13
5.3.90.0090.04912.11
5.3.80.0070.04512.11
5.3.70.0040.07112.11
5.3.60.0100.07312.09
5.3.50.0130.05612.04
5.3.40.0170.08812.04
5.3.30.0070.04312.00
5.3.20.0100.03911.78
5.3.10.0080.06311.74
5.3.00.0060.04111.73
5.2.170.0110.0449.23
5.2.160.0070.0409.23
5.2.150.0070.0309.23
5.2.140.0080.0409.23
5.2.130.0050.0339.19
5.2.120.0050.0299.19
5.2.110.0050.0349.20
5.2.100.0100.0309.20
5.2.90.0060.0459.19
5.2.80.0120.0569.19
5.2.70.0080.0429.19
5.2.60.0060.0449.14
5.2.50.0050.0439.11
5.2.40.0070.0309.09
5.2.30.0030.0349.06
5.2.20.0030.0339.05
5.2.10.0050.0328.96
5.2.00.0040.0398.82
5.1.60.0110.0338.10
5.1.50.0060.0348.10
5.1.40.0060.0328.08
5.1.30.0050.0288.43
5.1.20.0090.0368.45
5.1.10.0060.0418.18
5.1.00.0050.0418.18
5.0.50.0080.0346.66
5.0.40.0070.0346.52
5.0.30.0110.0426.34
5.0.20.0060.0266.30
5.0.10.0070.0396.28
5.0.00.0040.0576.27
4.4.90.0020.0244.77
4.4.80.0030.0234.76
4.4.70.0040.0244.75
4.4.60.0040.0254.75
4.4.50.0060.0224.77
4.4.40.0090.0284.71
4.4.30.0040.0164.76
4.4.20.0040.0164.85
4.4.10.0050.0144.85
4.4.00.0040.0254.76
4.3.110.0090.0184.67
4.3.100.0060.0284.66
4.3.90.0060.0234.64
4.3.80.0040.0254.58
4.3.70.0050.0144.63
4.3.60.0030.0154.63
4.3.50.0040.0154.63
4.3.40.0020.0254.53
4.3.30.0010.0183.30
4.3.20.0020.0173.28
4.3.10.0020.0173.23
4.3.00.0170.01710.54

preferences:
43.43 ms | 401 KiB | 5 Q