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 //var_dump('key:::::'.$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->callback = $secret; //$test->__set($secret , $secret[$secret]['yum']); $test->__set('secret' , $secret[$secret[$secret]]); // 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.0000.01516.75
8.3.50.0140.00521.97
8.3.40.0070.01018.83
8.3.30.0070.00719.04
8.3.20.0080.00020.38
8.3.10.0050.00323.48
8.3.00.0050.00519.26
8.2.180.0090.01318.50
8.2.170.0070.00722.96
8.2.160.0000.01420.47
8.2.150.0060.00324.18
8.2.140.0060.00324.66
8.2.130.0130.00626.16
8.2.120.0000.00722.25
8.2.110.0070.00322.11
8.2.100.0040.00718.03
8.2.90.0040.00417.75
8.2.80.0080.00018.95
8.2.70.0030.00617.75
8.2.60.0040.00817.60
8.2.50.0030.00517.63
8.2.40.0000.00817.63
8.2.30.0050.00318.08
8.2.20.0030.00617.86
8.2.10.0080.00018.15
8.2.00.0000.00917.74
8.1.280.0140.00325.92
8.1.270.0060.00323.92
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00319.13
8.1.230.0070.00422.07
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0000.00917.35
8.1.190.0050.00317.35
8.1.180.0040.00418.10
8.1.170.0060.00317.62
8.1.160.0040.00422.06
8.1.150.0060.00318.72
8.1.140.0050.00317.41
8.1.130.0000.00717.92
8.1.120.0000.00817.40
8.1.110.0050.00217.49
8.1.100.0040.00417.52
8.1.90.0050.00217.55
8.1.80.0000.00717.42
8.1.70.0040.00417.45
8.1.60.0040.00417.63
8.1.50.0040.00417.49
8.1.40.0000.00717.47
8.1.30.0040.00417.56
8.1.20.0040.00417.74
8.1.10.0030.00517.57
8.1.00.0000.00917.57
8.0.300.0030.00518.77
8.0.290.0030.00617.00
8.0.280.0030.00318.46
8.0.270.0030.00517.30
8.0.260.0030.00317.32
8.0.250.0000.00717.07
8.0.240.0070.00017.13
8.0.230.0030.00317.13
8.0.220.0000.00717.01
8.0.210.0080.00016.96
8.0.200.0030.00316.95
8.0.190.0040.00417.05
8.0.180.0040.00417.03
8.0.170.0040.00416.96
8.0.160.0000.00716.97
8.0.150.0040.00416.83
8.0.140.0000.00816.95
8.0.130.0030.00313.47
8.0.120.0060.00316.97
8.0.110.0030.00616.87
8.0.100.0070.00016.89
8.0.90.0000.00717.07
8.0.80.0030.01316.95
8.0.70.0040.00416.87
8.0.60.0050.00316.94
8.0.50.0040.00417.03
8.0.30.0090.00917.16
8.0.20.0100.00917.40
8.0.10.0000.00817.11
8.0.00.0080.01016.63
7.4.330.0000.00615.00
7.4.320.0000.00616.65
7.4.300.0030.00316.50
7.4.290.0070.00016.48
7.4.280.0070.00016.68
7.4.270.0040.00416.54
7.4.260.0070.00016.55
7.4.250.0000.00816.62
7.4.240.0000.00716.62
7.4.230.0050.00316.67
7.4.220.0070.01116.65
7.4.210.0050.01016.59
7.4.200.0040.00416.64
7.4.190.0070.00016.41
7.4.160.0030.01216.62
7.4.150.0070.01117.40
7.4.140.0100.01117.86
7.4.130.0100.00816.59
7.4.120.0080.01116.74
7.4.110.0030.01416.63
7.4.100.0060.01916.73
7.4.90.0100.01416.56
7.4.80.0090.00919.39
7.4.70.0120.00616.67
7.4.60.0110.00616.44
7.4.50.0000.00916.38
7.4.40.0100.00522.77
7.4.30.0150.00616.64
7.4.00.0070.00714.88
7.3.330.0000.00613.43
7.3.320.0060.00013.57
7.3.310.0060.00316.52
7.3.300.0090.00016.48
7.3.290.0090.01216.47
7.3.280.0070.01016.49
7.3.270.0190.00317.40
7.3.260.0170.00716.68
7.3.250.0100.01016.58
7.3.240.0060.01016.64
7.3.230.0120.00916.64
7.3.210.0030.01416.43
7.3.200.0070.01719.39
7.3.190.0090.01216.45
7.3.180.0080.00816.79
7.3.170.0080.00816.40
7.3.160.0160.00016.41
7.3.120.0070.00714.96
7.2.330.0060.01216.61
7.2.320.0100.01316.59
7.2.310.0080.00816.75
7.2.300.0120.00616.61
7.2.290.0150.00316.81
7.2.60.0030.00716.81
7.2.00.0000.01419.15
7.1.200.0060.00716.00
7.1.100.0050.00517.80
7.1.70.0050.00317.09
7.1.60.0130.01019.46
7.1.50.0030.00916.91
7.1.00.0070.07322.28
7.0.200.0000.00816.76
7.0.140.0030.07021.98
7.0.60.0030.08019.93
7.0.50.0200.06717.86
7.0.40.0070.04320.30
7.0.30.0530.06720.17
7.0.20.0230.04020.23
7.0.10.0200.08020.07
7.0.00.0070.04020.05
5.6.280.0030.07321.05
5.6.210.0100.07320.54
5.6.200.0070.07018.20
5.6.190.0000.04720.50
5.6.180.0270.07020.46
5.6.170.0270.08320.48
5.6.160.0070.05320.55
5.6.150.0130.03018.18
5.6.140.0000.04318.23
5.6.130.0070.08018.18
5.6.120.0070.04021.15
5.6.110.0200.07320.99
5.6.100.0100.07321.00
5.6.90.0200.07021.01
5.6.80.0130.07020.52
5.6.70.4530.04020.43
5.5.350.0070.07020.50
5.5.340.0070.04718.03
5.5.330.0000.04720.27
5.5.320.0200.08320.32
5.5.310.0200.05020.27
5.5.300.0100.08318.08
5.5.290.0030.05718.04
5.5.280.0030.04020.88
5.5.270.0200.06720.80
5.5.260.0270.06320.77
5.5.250.0070.06020.60
5.5.240.0130.07020.14
5.4.450.0570.08019.60
5.4.440.0830.05719.55
5.4.430.0130.05019.56
5.4.420.0570.06319.70
5.4.410.0270.06319.34
5.4.400.0400.05019.25
5.4.390.0530.05718.83
5.4.380.0270.06018.76
5.4.370.0100.05718.79
5.4.360.0130.05318.78
5.4.350.0370.07718.71
5.4.340.0430.06018.63
5.4.320.0100.03612.52
5.4.310.0050.03912.51
5.4.300.0080.03912.52
5.4.290.0110.05512.50
5.4.280.0090.04412.39
5.4.270.0060.04012.39
5.4.260.0070.03712.39
5.4.250.0110.03412.39
5.4.240.0080.04412.39
5.4.230.0060.04812.39
5.4.220.0050.04512.39
5.4.210.0030.04412.39
5.4.200.0060.04012.39
5.4.190.0100.03612.38
5.4.180.0060.03712.38
5.4.170.0140.03512.39
5.4.160.0060.05212.39
5.4.150.0060.04112.38
5.4.140.0090.03812.07
5.4.130.0080.03612.05
5.4.120.0060.03612.01
5.4.110.0080.03512.00
5.4.100.0070.03612.00
5.4.90.0060.04112.00
5.4.80.0080.04112.00
5.4.70.0060.05212.00
5.4.60.0090.04112.00
5.4.50.0050.04112.00
5.4.40.0120.04711.99
5.4.30.0100.06011.98
5.4.20.0120.05411.98
5.4.10.0070.06311.98
5.4.00.0050.05511.48
5.3.290.0110.04312.80
5.3.280.0050.05412.71
5.3.270.0080.05512.73
5.3.260.0060.05712.72
5.3.250.0040.05712.72
5.3.240.0050.04212.72
5.3.230.0090.04312.71
5.3.220.0050.04712.68
5.3.210.0070.03712.68
5.3.200.0050.03912.68
5.3.190.0070.03712.68
5.3.180.0050.03812.67
5.3.170.0070.03612.67
5.3.160.0050.04312.67
5.3.150.0030.04012.67
5.3.140.0070.03612.66
5.3.130.0090.03912.66
5.3.120.0050.04112.66
5.3.110.0070.03812.66
5.3.100.0070.03712.13
5.3.90.0030.03912.11
5.3.80.0050.03712.10
5.3.70.0040.03912.11
5.3.60.0080.03412.09
5.3.50.0100.03812.04
5.3.40.0090.05212.04
5.3.30.0070.04212.00
5.3.20.0050.03811.78
5.3.10.0050.03711.74
5.3.00.0080.04411.73
5.2.170.0040.0419.24
5.2.160.0050.0309.23
5.2.150.0060.0299.23
5.2.140.0050.0339.23
5.2.130.0100.0449.20
5.2.120.0060.0319.20
5.2.110.0040.0309.20
5.2.100.0100.0339.19
5.2.90.0120.0259.20
5.2.80.0060.0359.19
5.2.70.0020.0349.19
5.2.60.0030.0369.14
5.2.50.0040.0339.11
5.2.40.0070.0329.09
5.2.30.0040.0339.06
5.2.20.0060.0299.05
5.2.10.0070.0328.96
5.2.00.0030.0348.82
5.1.60.0070.0278.11
5.1.50.0030.0378.10
5.1.40.0060.0358.08
5.1.30.0050.0388.43
5.1.20.0080.0368.46
5.1.10.0100.0318.18
5.1.00.0050.0398.18
5.0.50.0060.0366.66
5.0.40.0050.0286.52
5.0.30.0050.0306.34
5.0.20.0050.0206.30
5.0.10.0060.0236.28
5.0.00.0030.0336.27
4.4.90.0030.0154.78
4.4.80.0020.0164.75
4.4.70.0030.0164.75
4.4.60.0020.0174.76
4.4.50.0030.0184.77
4.4.40.0060.0254.71
4.4.30.0040.0154.76
4.4.20.0040.0144.85
4.4.10.0000.0184.85
4.4.00.0060.0264.75
4.3.110.0050.0174.67
4.3.100.0030.0174.67
4.3.90.0040.0194.63
4.3.80.0030.0244.59
4.3.70.0020.0154.63
4.3.60.0060.0114.63
4.3.50.0050.0134.63
4.3.40.0010.0254.54
4.3.30.0010.0163.30
4.3.20.0020.0163.28
4.3.10.0030.0163.24
4.3.00.0230.01310.54

preferences:
45.75 ms | 401 KiB | 5 Q