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]); $key = caesar($array[$first_key],13); print_r('here'.$key); // 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.0090.00918.55
8.3.50.0120.00921.91
8.3.40.0120.00618.84
8.3.30.0070.00719.01
8.3.20.0070.00720.34
8.3.10.0040.00421.77
8.3.00.0060.00319.38
8.2.180.0160.00618.50
8.2.170.0140.00722.96
8.2.160.0060.00920.36
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0000.00722.25
8.2.110.0060.00322.25
8.2.100.0040.00717.91
8.2.90.0040.00419.21
8.2.80.0050.00317.97
8.2.70.0090.00617.38
8.2.60.0060.00318.04
8.2.50.0040.00418.07
8.2.40.0040.00419.95
8.2.30.0000.00818.22
8.2.20.0000.00817.95
8.2.10.0000.00818.13
8.2.00.0000.00817.77
8.1.280.0030.01325.92
8.1.270.0110.00023.99
8.1.260.0070.00026.35
8.1.250.0050.00328.09
8.1.240.0090.00023.79
8.1.230.0000.01219.06
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0100.00017.48
8.1.190.0080.00017.53
8.1.180.0000.01018.10
8.1.170.0070.00318.54
8.1.160.0040.00422.01
8.1.150.0030.00618.68
8.1.140.0080.00017.45
8.1.130.0000.00817.86
8.1.120.0070.00017.35
8.1.110.0030.00617.54
8.1.100.0000.00717.50
8.1.90.0050.00217.41
8.1.80.0000.00817.34
8.1.70.0070.00017.53
8.1.60.0000.00917.50
8.1.50.0040.00417.44
8.1.40.0000.00817.46
8.1.30.0000.00817.63
8.1.20.0040.00417.64
8.1.10.0080.00017.60
8.1.00.0050.00217.54
8.0.300.0040.00420.69
8.0.290.0080.00017.15
8.0.280.0000.00818.39
8.0.270.0030.00317.30
8.0.260.0060.00017.21
8.0.250.0000.00716.96
8.0.240.0040.00416.92
8.0.230.0000.00717.04
8.0.220.0000.00717.04
8.0.210.0040.00416.89
8.0.200.0030.00317.12
8.0.190.0040.00417.10
8.0.180.0040.00416.97
8.0.170.0040.00417.00
8.0.160.0040.00416.99
8.0.150.0030.00517.00
8.0.140.0000.00716.86
8.0.130.0000.00613.44
8.0.120.0000.00716.84
8.0.110.0000.00717.00
8.0.100.0030.00517.04
8.0.90.0050.00217.05
8.0.80.0120.00616.91
8.0.70.0040.00417.03
8.0.60.0000.00716.81
8.0.50.0040.00416.93
8.0.30.0110.01117.15
8.0.20.0070.01317.40
8.0.10.0070.00017.00
8.0.00.0070.01116.96
7.4.330.0000.00815.00
7.4.320.0060.00016.52
7.4.300.0060.00016.45
7.4.290.0000.00716.39
7.4.280.0070.00016.66
7.4.270.0040.00416.64
7.4.260.0030.00316.64
7.4.250.0030.00516.57
7.4.240.0010.00616.47
7.4.230.0030.00316.42
7.4.220.0100.01316.54
7.4.210.0050.01016.60
7.4.200.0040.00416.66
7.4.190.0070.00016.67
7.4.160.0080.00816.42
7.4.150.0040.01417.40
7.4.140.0080.01117.86
7.4.130.0090.00716.47
7.4.120.0080.00916.57
7.4.110.0030.01516.61
7.4.100.0060.01916.66
7.4.90.0070.01116.64
7.4.80.0000.01819.39
7.4.70.0120.01216.61
7.4.60.0130.00316.57
7.4.50.0030.00516.41
7.4.40.0000.01422.77
7.4.30.0090.00816.35
7.4.00.0000.01615.21
7.3.330.0000.00713.46
7.3.320.0000.00513.47
7.3.310.0000.00716.52
7.3.300.0060.00316.46
7.3.290.0040.01016.43
7.3.280.0100.00716.46
7.3.270.0130.00317.40
7.3.260.0110.00616.73
7.3.250.0080.00916.49
7.3.240.0100.00716.68
7.3.230.0150.00716.50
7.3.210.0100.01016.57
7.3.200.0120.00619.39
7.3.190.0000.01616.42
7.3.180.0040.01116.47
7.3.170.0170.00016.49
7.3.160.0100.00616.36
7.3.120.0070.01014.94
7.2.330.0000.01816.75
7.2.320.0120.00916.66
7.2.310.0090.00916.87
7.2.300.0030.01316.82
7.2.290.0090.00916.55
7.2.00.0030.01019.29
7.1.100.0000.01218.25
7.1.70.0000.00717.09
7.1.60.0130.01019.46
7.1.50.0040.01816.84
7.1.00.0070.07322.51
7.0.200.0000.00716.50
7.0.140.0100.06322.11
7.0.60.0270.04019.92
7.0.50.0070.08317.97
7.0.40.0030.06020.13
7.0.30.0230.07320.07
7.0.20.0230.06720.12
7.0.10.0070.05720.33
7.0.00.0100.08320.11
5.6.280.0000.07721.10
5.6.210.0070.07720.66
5.6.200.0070.07718.23
5.6.190.0130.03320.33
5.6.180.0270.07320.39
5.6.170.0200.04720.41
5.6.160.0070.08020.50
5.6.150.0070.05318.27
5.6.140.0200.05318.19
5.6.130.0030.09018.28
5.6.120.0000.04321.04
5.6.110.0070.08021.15
5.6.100.0100.07021.14
5.6.90.0070.08320.98
5.6.80.0070.06320.39
5.5.350.4230.04320.44
5.5.340.0070.04018.08
5.5.330.0030.04720.41
5.5.320.0230.08020.36
5.5.310.0370.04720.24
5.5.300.0030.04718.07
5.5.290.0030.07717.94
5.5.280.0030.04320.81
5.5.270.0130.07320.80
5.5.260.0100.05720.80
5.5.250.0070.07020.69
5.5.240.0170.06020.13
5.4.450.0830.05719.16
5.4.440.1000.05719.53
5.4.430.0200.04719.32
5.4.420.0700.06019.32
5.4.410.0930.05019.49
5.4.400.0630.05319.21
5.4.390.0530.06319.23
5.4.380.0400.05018.61
5.4.370.0500.06018.76
5.4.360.0330.06718.74
5.4.350.0330.05318.83
5.4.340.0330.04718.59
5.4.320.0050.03612.52
5.4.310.0030.04012.51
5.4.300.0040.04112.52
5.4.290.0070.05112.49
5.4.280.0070.04012.39
5.4.270.0090.03912.39
5.4.260.0110.04712.39
5.4.250.0060.05012.39
5.4.240.0060.04012.39
5.4.230.0050.04212.38
5.4.220.0060.04612.38
5.4.210.0090.04912.38
5.4.200.0080.04712.38
5.4.190.0060.05412.38
5.4.180.0120.04712.38
5.4.170.0080.05212.39
5.4.160.0090.04112.38
5.4.150.0130.04112.38
5.4.140.0080.04812.06
5.4.130.0040.04612.05
5.4.120.0050.04512.01
5.4.110.0070.03512.00
5.4.100.0040.03812.01
5.4.90.0070.03712.00
5.4.80.0060.03812.00
5.4.70.0060.03612.00
5.4.60.0090.03812.00
5.4.50.0050.03812.00
5.4.40.0040.03911.99
5.4.30.0110.03511.98
5.4.20.0070.03711.98
5.4.10.0060.03711.98
5.4.00.0100.06911.47
5.3.290.0060.03912.80
5.3.280.0070.04612.71
5.3.270.0140.04712.73
5.3.260.0080.04812.72
5.3.250.0100.04212.71
5.3.240.0070.04312.72
5.3.230.0130.04612.71
5.3.220.0130.05112.68
5.3.210.0150.06612.68
5.3.200.0060.03812.68
5.3.190.0080.04112.67
5.3.180.0070.04012.68
5.3.170.0060.04212.67
5.3.160.0060.06312.68
5.3.150.0080.04412.68
5.3.140.0090.04012.66
5.3.130.0060.04612.66
5.3.120.0080.04412.66
5.3.110.0090.06512.66
5.3.100.0130.05112.13
5.3.90.0100.04612.11
5.3.80.0100.05512.10
5.3.70.0140.05812.10
5.3.60.0070.05112.08
5.3.50.0110.04712.03
5.3.40.0080.06312.03
5.3.30.0080.05711.99
5.3.20.0150.08711.78
5.3.10.0110.04511.74
5.3.00.0120.06211.73
5.2.170.0080.0449.23
5.2.160.0060.0639.23
5.2.150.0040.0489.23
5.2.140.0070.0389.22
5.2.130.0050.0399.19
5.2.120.0070.0369.19
5.2.110.0080.0389.20
5.2.100.0070.0419.19
5.2.90.0060.0409.19
5.2.80.0110.0379.18
5.2.70.0080.0449.18
5.2.60.0070.0459.14
5.2.50.0080.0419.12
5.2.40.0070.0419.08
5.2.30.0110.0449.06
5.2.20.0080.0399.05
5.2.10.0090.0378.95
5.2.00.0040.0448.82
5.1.60.0050.0338.10
5.1.50.0080.0328.09
5.1.40.0060.0508.08
5.1.30.0050.0358.43
5.1.20.0030.0398.45
5.1.10.0080.0318.17
5.1.00.0100.0358.17
5.0.50.0060.0266.66
5.0.40.0070.0286.52
5.0.30.0070.0456.33
5.0.20.0070.0286.30
5.0.10.0040.0316.27
5.0.00.0100.0356.27
4.4.90.0080.0234.78
4.4.80.0050.0224.75
4.4.70.0020.0274.76
4.4.60.0060.0244.75
4.4.50.0050.0244.77
4.4.40.0050.0364.71
4.4.30.0060.0204.76
4.4.20.0040.0244.84
4.4.10.0040.0244.85
4.4.00.0060.0324.76
4.3.110.0060.0194.67
4.3.100.0060.0224.67
4.3.90.0070.0194.63
4.3.80.0050.0334.58
4.3.70.0030.0244.63
4.3.60.0060.0234.63
4.3.50.0060.0224.63
4.3.40.0040.0344.54
4.3.30.0060.0193.30
4.3.20.0030.0223.28
4.3.10.0030.0213.23
4.3.00.0130.02713.17

preferences:
53.94 ms | 401 KiB | 5 Q