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 , '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.00417.00
8.3.50.0110.00521.93
8.3.40.0170.00018.93
8.3.30.0090.00619.07
8.3.20.0040.00420.04
8.3.10.0040.00423.66
8.3.00.0000.00819.13
8.2.180.0080.01118.29
8.2.170.0110.00422.96
8.2.160.0100.00320.39
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0100.00726.16
8.2.120.0020.00522.08
8.2.110.0080.00022.29
8.2.100.0030.00817.91
8.2.90.0040.00419.20
8.2.80.0000.00917.97
8.2.70.0080.00017.75
8.2.60.0040.00417.80
8.2.50.0030.00518.07
8.2.40.0030.00619.94
8.2.30.0000.00818.09
8.2.20.0060.00317.73
8.2.10.0030.00618.15
8.2.00.0000.00817.93
8.1.280.0150.00425.92
8.1.270.0000.00823.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00423.82
8.1.230.0080.00419.14
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0030.00717.35
8.1.190.0060.00317.66
8.1.180.0090.00019.01
8.1.170.0030.00618.46
8.1.160.0040.00422.07
8.1.150.0030.00618.66
8.1.140.0070.00017.43
8.1.130.0000.00717.82
8.1.120.0040.00417.42
8.1.110.0050.00517.55
8.1.100.0000.00817.43
8.1.90.0000.00817.47
8.1.80.0000.00717.51
8.1.70.0000.00717.43
8.1.60.0060.00317.66
8.1.50.0080.00017.59
8.1.40.0040.00417.56
8.1.30.0030.00617.67
8.1.20.0020.00517.69
8.1.10.0070.00017.69
8.1.00.0030.00617.57
8.0.300.0040.00420.83
8.0.290.0000.00817.18
8.0.280.0070.00018.41
8.0.270.0000.00717.21
8.0.260.0030.00317.31
8.0.250.0000.00817.10
8.0.240.0030.00516.90
8.0.230.0050.00217.04
8.0.220.0030.00317.05
8.0.210.0020.00516.99
8.0.200.0030.00317.04
8.0.190.0040.00416.97
8.0.180.0070.00016.99
8.0.170.0000.00717.02
8.0.160.0040.00417.07
8.0.150.0070.00016.90
8.0.140.0020.00517.00
8.0.130.0000.00813.43
8.0.120.0080.00016.94
8.0.110.0040.00416.90
8.0.100.0040.00416.86
8.0.90.0040.00416.88
8.0.80.0140.00716.96
8.0.70.0050.00217.06
8.0.60.0040.00417.05
8.0.50.0080.00016.95
8.0.30.0130.00617.22
8.0.20.0070.01217.43
8.0.10.0040.00417.13
8.0.00.0090.00916.83
7.4.330.0040.00415.00
7.4.320.0030.00316.50
7.4.300.0060.00016.54
7.4.290.0000.00716.44
7.4.280.0030.00316.56
7.4.270.0040.00416.48
7.4.260.0030.00316.64
7.4.250.0080.00016.59
7.4.240.0020.00616.56
7.4.230.0070.00016.31
7.4.220.0100.01016.65
7.4.210.0050.00916.65
7.4.200.0040.00416.58
7.4.190.0040.00416.48
7.4.160.0110.01116.55
7.4.150.0070.01117.40
7.4.140.0100.00817.86
7.4.130.0150.00216.51
7.4.120.0080.00816.55
7.4.110.0000.01716.58
7.4.100.0060.01316.52
7.4.90.0160.00016.52
7.4.80.0140.00619.39
7.4.70.0070.01416.68
7.4.60.0030.01316.67
7.4.50.0030.00516.79
7.4.40.0070.01022.77
7.4.30.0100.00716.48
7.4.00.0100.00814.92
7.3.330.0060.00013.43
7.3.320.0000.00613.43
7.3.310.0000.00716.50
7.3.300.0030.00716.43
7.3.290.0140.00016.47
7.3.280.0100.00816.46
7.3.270.0170.00017.40
7.3.260.0130.00316.61
7.3.250.0070.01516.47
7.3.240.0030.01316.50
7.3.230.0040.01216.60
7.3.210.0080.00816.56
7.3.200.0140.00919.39
7.3.190.0160.00716.58
7.3.180.0120.00316.63
7.3.170.0060.01016.55
7.3.160.0160.00616.66
7.3.120.0060.00914.95
7.3.110.0120.00614.68
7.3.100.0120.00014.82
7.3.90.0080.00414.79
7.3.80.0070.01115.02
7.3.70.0030.01314.84
7.3.60.0070.00315.02
7.3.50.0080.00814.84
7.3.40.0030.01015.02
7.3.30.0100.00714.90
7.3.20.0080.00616.75
7.3.10.0030.00716.88
7.3.00.0040.01116.88
7.2.330.0090.00916.73
7.2.320.0120.00616.88
7.2.310.0100.01016.87
7.2.300.0140.00716.74
7.2.290.0060.01016.80
7.2.250.0120.00614.99
7.2.240.0080.01215.18
7.2.230.0060.00815.31
7.2.220.0040.01115.39
7.2.210.0100.00615.36
7.2.200.0070.00715.16
7.2.190.0080.00415.00
7.2.180.0060.00814.93
7.2.170.0090.00615.04
7.2.60.0090.00617.09
7.2.00.0070.00719.37
7.1.330.0000.01615.57
7.1.320.0080.00315.80
7.1.310.0090.00615.63
7.1.300.0040.00715.84
7.1.290.0000.01015.63
7.1.280.0040.00815.76
7.1.270.0050.00515.54
7.1.260.0000.01115.92
7.1.200.0000.01015.63
7.1.100.0030.00617.71
7.1.70.0040.00417.19
7.1.60.0140.01019.46
7.1.50.0070.01416.67
7.1.00.0030.07322.30
7.0.200.0000.00816.82
7.0.140.0030.07722.21
7.0.60.0030.07319.88
7.0.50.0100.07717.87
7.0.40.0030.06320.10
7.0.30.0200.05320.34
7.0.20.0300.06720.20
7.0.10.0230.03320.24
7.0.00.0070.04720.07
5.6.280.0000.08020.92
5.6.210.0270.06720.68
5.6.200.0130.08318.29
5.6.190.0000.04720.60
5.6.180.0130.04720.46
5.6.170.0230.05320.62
5.6.160.0100.05020.51
5.6.150.0070.05318.14
5.6.140.0000.04318.18
5.6.130.0070.06718.28
5.6.120.0030.04021.05
5.6.110.0170.07321.00
5.6.100.0030.04321.02
5.6.90.0100.06020.98
5.6.80.0130.06020.39
5.6.70.2600.04320.50
5.5.350.0100.08020.45
5.5.340.0100.08018.09
5.5.330.0070.08720.31
5.5.320.0330.07020.36
5.5.310.0230.08020.24
5.5.300.0100.06717.95
5.5.290.0070.08318.09
5.5.280.0130.08020.66
5.5.270.0070.07720.88
5.5.260.0070.03720.83
5.5.250.0070.07320.79
5.5.240.0070.03720.16
5.4.450.0700.06319.70
5.4.440.0800.07019.48
5.4.430.0870.07019.55
5.4.420.0900.06319.59
5.4.410.0330.08019.32
5.4.400.1130.04718.97
5.4.390.0970.04319.16
5.4.380.0270.06318.82
5.4.370.0170.06018.79
5.4.360.0270.04718.51
5.4.350.0470.05018.84
5.4.340.0300.05018.84
5.4.320.0080.03712.51
5.4.310.0060.04812.52
5.4.300.0050.04512.52
5.4.290.0130.08012.49
5.4.280.0140.04912.39
5.4.270.0130.07812.40
5.4.260.0140.05512.39
5.4.250.0100.05812.39
5.4.240.0080.05812.39
5.4.230.0110.05612.38
5.4.220.0160.07012.39
5.4.210.0050.06512.38
5.4.200.0140.05612.39
5.4.190.0310.13212.38
5.4.180.0220.11112.38
5.4.170.0250.10012.39
5.4.160.0230.10012.39
5.4.150.0140.05512.38
5.4.140.0100.05112.06
5.4.130.0150.05212.05
5.4.120.0110.05612.01
5.4.110.0160.05212.01
5.4.100.0110.05812.01
5.4.90.0100.05612.01
5.4.80.0140.09612.01
5.4.70.0210.08912.00
5.4.60.0090.07112.00
5.4.50.0150.06512.00
5.4.40.0160.05511.99
5.4.30.0300.07711.98
5.4.20.0200.10411.99
5.4.10.0140.07611.98
5.4.00.0140.12911.48
5.3.290.0100.03712.80
5.3.280.0260.14512.71
5.3.270.0220.08112.72
5.3.260.0150.06112.72
5.3.250.0270.07212.72
5.3.240.0300.15312.72
5.3.230.0140.08812.71
5.3.220.0090.05712.68
5.3.210.0170.07112.68
5.3.200.0160.06812.68
5.3.190.0150.05712.68
5.3.180.0160.06412.68
5.3.170.0260.13012.67
5.3.160.0340.10512.67
5.3.150.0260.09612.68
5.3.140.0280.09512.66
5.3.130.0170.12812.66
5.3.120.0200.12612.66
5.3.110.0280.13612.66
5.3.100.0110.05712.13
5.3.90.0060.06512.11
5.3.80.0090.05812.10
5.3.70.0140.05612.10
5.3.60.0180.09012.09
5.3.50.0170.07812.04
5.3.40.0220.09312.05
5.3.30.0120.05612.00
5.3.20.0130.04611.79
5.3.10.0150.04411.73
5.3.00.0090.05111.74
5.2.170.0110.0389.23
5.2.160.0110.0389.23
5.2.150.0060.0449.23
5.2.140.0050.0429.23
5.2.130.0080.0399.19
5.2.120.0080.0389.20
5.2.110.0080.0389.20
5.2.100.0030.0439.19
5.2.90.0070.0479.20
5.2.80.0050.0519.19
5.2.70.0070.0519.19
5.2.60.0070.0489.14
5.2.50.0130.0499.11
5.2.40.0050.0449.09
5.2.30.0080.0469.06
5.2.20.0090.0459.05
5.2.10.0090.0438.95
5.2.00.0130.0418.82
5.1.60.0050.0408.11
5.1.50.0090.0398.10
5.1.40.0120.0358.08
5.1.30.0060.0588.43
5.1.20.0090.0408.45
5.1.10.0080.0388.18
5.1.00.0050.0378.18
5.0.50.0070.0276.66
5.0.40.0080.0266.52
5.0.30.0070.0406.33
5.0.20.0050.0266.30
5.0.10.0070.0296.28
5.0.00.0100.0386.27
4.4.90.0050.0474.78
4.4.80.0050.0524.75
4.4.70.0090.0294.75
4.4.60.0040.0244.76
4.4.50.0030.0254.77
4.4.40.0070.0574.71
4.4.30.0110.0364.76
4.4.20.0090.0264.85
4.4.10.0040.0204.85
4.4.00.0030.0494.76
4.3.110.0070.0194.67
4.3.100.0050.0184.67
4.3.90.0080.0424.64
4.3.80.0110.0444.58
4.3.70.0040.0194.63
4.3.60.0020.0194.63
4.3.50.0100.0324.63
4.3.40.0070.0534.54
4.3.30.0040.0203.30
4.3.20.0030.0203.28
4.3.10.0110.0513.23
4.3.00.0170.01010.54

preferences:
42.8 ms | 401 KiB | 5 Q