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; } $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.0110.00416.84
8.3.50.0130.00522.11
8.3.40.0140.00418.96
8.3.30.0080.00819.04
8.3.20.0040.00420.34
8.3.10.0080.00023.61
8.3.00.0040.00419.38
8.2.180.0120.00418.54
8.2.170.0120.00622.96
8.2.160.0100.00720.52
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0080.00022.21
8.2.110.0060.00322.27
8.2.100.0060.00617.78
8.2.90.0040.00418.03
8.2.80.0000.00817.97
8.2.70.0060.00317.63
8.2.60.0040.00418.03
8.2.50.0000.00818.07
8.2.40.0000.00820.07
8.2.30.0070.00018.28
8.2.20.0030.00517.84
8.2.10.0040.00419.93
8.2.00.0060.00317.95
8.1.280.0000.01925.92
8.1.270.0000.00823.82
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00320.73
8.1.230.0060.00620.84
8.1.220.0060.00317.79
8.1.210.0030.00618.88
8.1.200.0040.00417.36
8.1.190.0000.00817.65
8.1.180.0060.00319.14
8.1.170.0000.00818.53
8.1.160.0000.00722.06
8.1.150.0030.00618.59
8.1.140.0000.00717.36
8.1.130.0000.00717.78
8.1.120.0070.00017.42
8.1.110.0030.00717.48
8.1.100.0000.00717.34
8.1.90.0000.00717.36
8.1.80.0070.00017.50
8.1.70.0050.00317.28
8.1.60.0030.00617.69
8.1.50.0050.00317.49
8.1.40.0040.00417.50
8.1.30.0030.00617.64
8.1.20.0000.00817.66
8.1.10.0040.00417.63
8.1.00.0040.00417.48
8.0.300.0000.00720.16
8.0.290.0000.00817.18
8.0.280.0000.00718.54
8.0.270.0030.00317.21
8.0.260.0000.00817.32
8.0.250.0070.00016.95
8.0.240.0080.00017.07
8.0.230.0050.00217.16
8.0.220.0070.00016.99
8.0.210.0000.00816.99
8.0.200.0030.00316.95
8.0.190.0000.00816.99
8.0.180.0000.00716.92
8.0.170.0000.00817.00
8.0.160.0080.00016.94
8.0.150.0000.00716.84
8.0.140.0000.00716.83
8.0.130.0030.00313.52
8.0.120.0000.00716.85
8.0.110.0030.00517.07
8.0.100.0040.00416.81
8.0.90.0040.00416.97
8.0.80.0000.01816.97
8.0.70.0040.00416.97
8.0.60.0040.00416.96
8.0.50.0000.00816.78
8.0.30.0100.01017.02
8.0.20.0080.01017.40
8.0.10.0040.00417.11
8.0.00.0140.00516.84
7.4.330.0000.00715.00
7.4.320.0030.00316.59
7.4.300.0000.00616.63
7.4.290.0040.00416.65
7.4.280.0030.00316.63
7.4.270.0070.00016.69
7.4.260.0030.00316.63
7.4.250.0000.00816.46
7.4.240.0020.00516.55
7.4.230.0040.00416.65
7.4.220.0070.01116.51
7.4.210.0080.00916.61
7.4.200.0000.00716.66
7.4.190.0050.00216.78
7.4.160.0130.00316.70
7.4.150.0130.00317.40
7.4.140.0090.00817.86
7.4.130.0080.00916.61
7.4.120.0140.00316.49
7.4.110.0090.00916.67
7.4.100.0160.00416.60
7.4.90.0120.00616.64
7.4.80.0070.01719.39
7.4.70.0150.00416.57
7.4.60.0050.01116.58
7.4.50.0050.00016.39
7.4.40.0120.00022.77
7.4.30.0130.00916.52
7.4.00.0110.00414.89
7.3.330.0000.00613.38
7.3.320.0050.00013.41
7.3.310.0000.00716.50
7.3.300.0000.00816.42
7.3.290.0090.00916.52
7.3.280.0090.00916.54
7.3.270.0160.00317.40
7.3.260.0110.00716.46
7.3.250.0090.01116.45
7.3.240.0070.01416.48
7.3.230.0000.01816.52
7.3.210.0070.01016.50
7.3.200.0020.00819.39
7.3.190.0080.00816.68
7.3.180.0060.01616.54
7.3.170.0110.00416.58
7.3.160.0060.00916.55
7.3.120.0030.01415.10
7.2.330.0040.01316.61
7.2.320.0090.00916.80
7.2.310.0100.00716.89
7.2.300.0080.00816.69
7.2.290.0080.00916.77
7.2.00.0040.01119.51
7.1.100.0030.01018.23
7.1.70.0050.00317.35
7.1.60.0110.01419.46
7.1.50.0080.00316.67
7.1.00.0130.06722.45
7.0.200.0030.00616.73
7.0.140.0030.07322.19
7.0.60.0230.06019.85
7.0.50.0030.04717.74
7.0.40.0000.06320.27
7.0.30.0330.06720.07
7.0.20.0200.05320.06
7.0.10.0100.08320.19
7.0.00.0130.03720.22
5.6.280.0000.07721.16
5.6.210.0030.05020.70
5.6.200.0070.08018.19
5.6.190.0030.04320.50
5.6.180.0170.05320.64
5.6.170.0200.07020.47
5.6.160.0100.05320.39
5.6.150.0030.08718.25
5.6.140.0100.05318.29
5.6.130.0100.07318.28
5.6.120.0130.07020.98
5.6.110.0000.04320.97
5.6.100.0200.07321.05
5.6.90.0030.04020.99
5.6.80.0170.07020.39
5.6.70.4470.04020.50
5.5.350.0030.08320.43
5.5.340.0100.07718.09
5.5.330.0070.07020.57
5.5.320.0170.04320.27
5.5.310.0230.08320.36
5.5.300.0030.08717.98
5.5.290.0070.08018.08
5.5.280.0100.08020.70
5.5.270.0030.06020.65
5.5.260.0100.05320.86
5.5.250.0030.07720.70
5.5.240.0070.03720.22
5.4.450.0970.07019.57
5.4.440.0730.06019.18
5.4.430.0700.06719.52
5.4.420.0130.05319.64
5.4.410.0830.05319.43
5.4.400.1000.05719.25
5.4.390.0130.05318.83
5.4.380.0370.05018.84
5.4.370.1200.06318.76
5.4.360.0430.07318.73
5.4.350.0670.06018.51
5.4.340.0170.06318.48
5.4.320.0050.03612.52
5.4.310.0050.04012.51
5.4.300.0060.03512.51
5.4.290.0090.04912.49
5.4.280.0140.04412.39
5.4.270.0070.05912.39
5.4.260.0100.05312.39
5.4.250.0090.04412.39
5.4.240.0080.03912.39
5.4.230.0140.05212.38
5.4.220.0120.04012.39
5.4.210.0070.03712.38
5.4.200.0070.04212.38
5.4.190.0120.06012.38
5.4.180.0060.03912.38
5.4.170.0060.03812.39
5.4.160.0050.03912.38
5.4.150.0080.04212.38
5.4.140.0050.03912.06
5.4.130.0100.04312.05
5.4.120.0060.03912.01
5.4.110.0110.04612.00
5.4.100.0040.05312.00
5.4.90.0070.05312.00
5.4.80.0090.05412.01
5.4.70.0110.04512.00
5.4.60.0090.04612.00
5.4.50.0070.04912.00
5.4.40.0100.04811.98
5.4.30.0050.03911.98
5.4.20.0050.03811.98
5.4.10.0090.03411.98
5.4.00.0070.03611.47
5.3.290.0060.04012.80
5.3.280.0070.04212.71
5.3.270.0070.03912.73
5.3.260.0090.03712.72
5.3.250.0080.03812.72
5.3.240.0090.03712.72
5.3.230.0050.04012.71
5.3.220.0090.03612.68
5.3.210.0070.03912.68
5.3.200.0070.03812.68
5.3.190.0070.05512.68
5.3.180.0090.06112.68
5.3.170.0140.05512.67
5.3.160.0070.04812.67
5.3.150.0080.04412.67
5.3.140.0090.04112.66
5.3.130.0110.04412.66
5.3.120.0070.04412.66
5.3.110.0060.04312.66
5.3.100.0050.04112.13
5.3.90.0080.04612.11
5.3.80.0100.03412.09
5.3.70.0070.04812.10
5.3.60.0070.05612.09
5.3.50.0060.04812.04
5.3.40.0060.04512.03
5.3.30.0040.03911.99
5.3.20.0040.04011.77
5.3.10.0100.03611.73
5.3.00.0070.05611.72
5.2.170.0050.0379.23
5.2.160.0080.0269.23
5.2.150.0020.0339.23
5.2.140.0090.0299.23
5.2.130.0040.0329.19
5.2.120.0090.0329.19
5.2.110.0040.0319.20
5.2.100.0050.0299.19
5.2.90.0090.0319.19
5.2.80.0050.0359.18
5.2.70.0070.0339.18
5.2.60.0070.0309.14
5.2.50.0040.0339.11
5.2.40.0070.0329.08
5.2.30.0080.0349.05
5.2.20.0080.0309.04
5.2.10.0040.0318.95
5.2.00.0050.0318.82
5.1.60.0060.0258.10
5.1.50.0060.0348.09
5.1.40.0080.0268.08
5.1.30.0030.0328.42
5.1.20.0020.0328.45
5.1.10.0130.0318.17
5.1.00.0060.0308.17
5.0.50.0060.0206.66
5.0.40.0070.0176.52
5.0.30.0030.0336.33
5.0.20.0020.0236.29
5.0.10.0050.0296.28
5.0.00.0050.0306.27
4.4.90.0040.0164.78
4.4.80.0020.0184.76
4.4.70.0030.0164.75
4.4.60.0050.0174.76
4.4.50.0060.0154.77
4.4.40.0060.0294.71
4.4.30.0040.0174.76
4.4.20.0040.0154.84
4.4.10.0060.0174.85
4.4.00.0020.0284.76
4.3.110.0060.0194.67
4.3.100.0040.0214.67
4.3.90.0020.0244.64
4.3.80.0050.0304.58
4.3.70.0050.0154.63
4.3.60.0030.0164.63
4.3.50.0010.0214.63
4.3.40.0040.0254.54
4.3.30.0030.0223.30
4.3.20.0020.0223.28
4.3.10.0020.0223.23
4.3.00.0070.02013.17

preferences:
36.41 ms | 401 KiB | 5 Q