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 //$this->secret = $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->__set($secret , $secret['yum']); // 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.0040.01116.60
8.3.50.0070.01221.87
8.3.40.0150.01218.82
8.3.30.0040.01118.99
8.3.20.0050.00320.29
8.3.10.0020.00523.66
8.3.00.0040.00419.38
8.2.180.0120.00618.41
8.2.170.0070.01022.96
8.2.160.0120.00920.12
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0070.01026.16
8.2.120.0080.00022.32
8.2.110.0060.00322.19
8.2.100.0090.00317.84
8.2.90.0030.00519.09
8.2.80.0080.00017.97
8.2.70.0040.00417.63
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0000.00820.02
8.2.30.0030.00518.09
8.2.20.0000.00817.85
8.2.10.0000.00818.05
8.2.00.0100.00017.75
8.1.280.0100.01025.92
8.1.270.0000.00923.87
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.00923.77
8.1.230.0090.00319.10
8.1.220.0040.00417.76
8.1.210.0040.00418.77
8.1.200.0060.00317.36
8.1.190.0000.00917.54
8.1.180.0060.00319.26
8.1.170.0050.00318.50
8.1.160.0040.00422.11
8.1.150.0110.00018.68
8.1.140.0040.00417.40
8.1.130.0030.00317.78
8.1.120.0050.00317.43
8.1.110.0030.00717.46
8.1.100.0000.01017.50
8.1.90.0080.00017.47
8.1.80.0000.00817.54
8.1.70.0030.00317.44
8.1.60.0030.00517.66
8.1.50.0050.00517.56
8.1.40.0040.00417.59
8.1.30.0030.00517.68
8.1.20.0000.00817.56
8.1.10.0040.00417.50
8.1.00.0030.00617.44
8.0.300.0040.00420.80
8.0.290.0040.00417.29
8.0.280.0030.00318.52
8.0.270.0000.00717.30
8.0.260.0000.00617.21
8.0.250.0050.00317.00
8.0.240.0030.00617.09
8.0.230.0000.00717.03
8.0.220.0000.00717.07
8.0.210.0070.00017.00
8.0.200.0070.00016.96
8.0.190.0000.00817.06
8.0.180.0000.00716.90
8.0.170.0080.00017.03
8.0.160.0040.00416.82
8.0.150.0050.00216.88
8.0.140.0000.00817.00
8.0.130.0030.00313.51
8.0.120.0030.00516.95
8.0.110.0040.00416.99
8.0.100.0040.00417.07
8.0.90.0030.00517.02
8.0.80.0090.00616.95
8.0.70.0070.00016.88
8.0.60.0030.00517.05
8.0.50.0070.00016.99
8.0.30.0130.00717.21
8.0.20.0150.00717.40
8.0.10.0000.00717.16
8.0.00.0150.00616.84
7.4.330.0030.00315.00
7.4.320.0060.00016.55
7.4.300.0070.00016.56
7.4.290.0030.00316.57
7.4.280.0000.00716.54
7.4.270.0030.00516.53
7.4.260.0030.00316.59
7.4.250.0000.00816.56
7.4.240.0030.00316.57
7.4.230.0000.00716.39
7.4.220.0030.01316.65
7.4.210.0090.00716.64
7.4.200.0070.00016.68
7.4.190.0030.00316.60
7.4.160.0060.01016.50
7.4.150.0150.00917.40
7.4.140.0100.01117.86
7.4.130.0060.01116.73
7.4.120.0100.00816.65
7.4.110.0140.00316.40
7.4.100.0120.00616.73
7.4.90.0120.00616.66
7.4.80.0040.01519.39
7.4.70.0150.00916.72
7.4.60.0040.01216.53
7.4.50.0040.00416.30
7.4.40.0030.01022.77
7.4.30.0060.01016.51
7.4.00.0000.01715.09
7.3.330.0000.00713.26
7.3.320.0000.00613.44
7.3.310.0070.00016.37
7.3.300.0030.00516.39
7.3.290.0060.00916.47
7.3.280.0100.00916.45
7.3.270.0030.01417.40
7.3.260.0100.00716.59
7.3.250.0060.01316.47
7.3.240.0090.01216.47
7.3.230.0070.01516.39
7.3.210.0120.00416.51
7.3.200.0130.01219.39
7.3.190.0110.00616.43
7.3.180.0040.01516.63
7.3.170.0120.00316.62
7.3.160.0090.00716.55
7.3.120.0130.00514.98
7.3.110.0080.00914.81
7.3.100.0070.00715.01
7.3.90.0080.00815.07
7.3.80.0060.00915.04
7.3.70.0050.00714.96
7.3.60.0100.00314.96
7.3.50.0050.00614.99
7.3.40.0050.00714.98
7.3.30.0060.00514.93
7.3.20.0020.01016.46
7.3.10.0080.00816.57
7.3.00.0090.00616.53
7.2.330.0120.00616.84
7.2.320.0090.00816.89
7.2.310.0120.00416.74
7.2.300.0080.00816.56
7.2.290.0130.00316.89
7.2.240.0090.00815.19
7.2.230.0060.00915.16
7.2.220.0060.00815.17
7.2.210.0070.00714.89
7.2.200.0050.01215.00
7.2.190.0050.01215.17
7.2.180.0030.01215.08
7.2.170.0040.00915.22
7.2.160.0020.01515.10
7.2.150.0050.00616.97
7.2.140.0070.00917.03
7.2.130.0050.01116.69
7.2.120.0060.00916.93
7.2.110.0080.00716.79
7.2.100.0110.00716.62
7.2.90.0070.00816.80
7.2.80.0060.00816.81
7.2.70.0100.00916.81
7.2.60.0070.00816.90
7.2.50.0080.01116.77
7.2.40.0090.00816.87
7.2.30.0070.01016.83
7.2.20.0070.01116.99
7.2.10.0080.01116.94
7.2.00.0060.01017.65
7.1.330.0040.01315.74
7.1.320.0120.00415.91
7.1.310.0070.00615.82
7.1.300.0070.00715.76
7.1.290.0040.00915.86
7.1.280.0040.00515.55
7.1.270.0060.00615.71
7.1.260.0090.00315.69
7.1.250.0050.00915.75
7.1.200.0060.00615.79
7.1.100.0030.01018.16
7.1.70.0050.00317.11
7.1.60.0090.01619.46
7.1.50.0030.01534.76
7.1.00.0000.08022.48
7.0.200.0040.00416.84
7.0.140.0000.07721.95
7.0.60.0170.07319.95
7.0.50.0000.04317.88
7.0.40.0070.05720.41
7.0.30.0430.05020.10
7.0.20.0330.07320.10
7.0.10.0130.05020.08
7.0.00.0100.03720.15
5.6.280.0000.07720.92
5.6.210.0070.06720.77
5.6.200.0030.08718.15
5.6.190.0200.06720.33
5.6.180.0200.05720.55
5.6.170.0300.05020.44
5.6.160.0130.07020.46
5.6.150.0130.07018.16
5.6.140.0030.07718.28
5.6.130.0030.08018.18
5.6.120.0170.07021.06
5.6.110.0030.04021.00
5.6.100.0130.06021.12
5.6.90.0100.03320.98
5.6.80.0030.06320.53
5.6.70.3370.03720.40
5.5.350.0270.06320.36
5.5.340.0100.07318.03
5.5.330.0130.04020.21
5.5.320.0270.04720.29
5.5.310.0200.04020.23
5.5.300.0030.04018.08
5.5.290.0070.09017.99
5.5.280.0130.06320.87
5.5.270.0030.07020.96
5.5.260.0070.06320.96
5.5.250.0000.08320.70
5.5.240.3370.04020.29
5.4.450.0800.07319.54
5.4.440.0870.05719.45
5.4.430.0430.07019.46
5.4.420.1000.04319.37
5.4.410.0830.07019.44
5.4.400.0800.04719.13
5.4.390.0170.05019.22
5.4.380.0230.06018.73
5.4.370.0370.04318.80
5.4.360.0230.05318.48
5.4.350.0230.05718.79
5.4.340.0300.05018.84
5.4.320.0080.03512.51
5.4.310.0070.04012.51
5.4.300.0080.04112.52
5.4.290.0060.04312.50
5.4.280.0090.03312.39
5.4.270.0070.03612.39
5.4.260.0090.04912.39
5.4.250.0050.05512.39
5.4.240.0100.04312.39
5.4.230.0090.03512.38
5.4.220.0050.03912.39
5.4.210.0060.03612.39
5.4.200.0030.04112.38
5.4.190.0110.03312.38
5.4.180.0060.05112.39
5.4.170.0130.05712.39
5.4.160.0070.03812.39
5.4.150.0060.03712.38
5.4.140.0110.05012.06
5.4.130.0060.04112.05
5.4.120.0100.04412.01
5.4.110.0060.04012.01
5.4.100.0070.03712.01
5.4.90.0070.04212.01
5.4.80.0070.05312.01
5.4.70.0090.04912.00
5.4.60.0070.07512.01
5.4.50.0080.05112.00
5.4.40.0040.04011.99
5.4.30.0050.05111.98
5.4.20.0070.04211.99
5.4.10.0060.04011.98
5.4.00.0150.03911.48
5.3.290.0050.04512.80
5.3.280.0060.05712.70
5.3.270.0090.05512.73
5.3.260.0070.05812.72
5.3.250.0060.04912.72
5.3.240.0070.03712.72
5.3.230.0080.03712.70
5.3.220.0090.03512.68
5.3.210.0070.03912.68
5.3.200.0040.03912.68
5.3.190.0070.03912.68
5.3.180.0070.03612.67
5.3.170.0060.03812.67
5.3.160.0080.03812.68
5.3.150.0080.04012.68
5.3.140.0140.04112.66
5.3.130.0110.03712.66
5.3.120.0050.04112.66
5.3.110.0090.03712.66
5.3.100.0080.04812.13
5.3.90.0070.03812.11
5.3.80.0090.04112.10
5.3.70.0040.04512.11
5.3.60.0100.03512.08
5.3.50.0090.04312.04
5.3.40.0080.04912.04
5.3.30.0070.04812.00
5.3.20.0080.03411.78
5.3.10.0060.03511.74
5.3.00.0070.03611.73
5.2.170.0030.0329.23
5.2.160.0040.0309.23
5.2.150.0030.0329.23
5.2.140.0060.0339.23
5.2.130.0030.0319.20
5.2.120.0070.0289.20
5.2.110.0040.0309.20
5.2.100.0040.0449.19
5.2.90.0070.0419.20
5.2.80.0060.0439.19
5.2.70.0050.0329.19
5.2.60.0060.0309.14
5.2.50.0050.0349.11
5.2.40.0060.0339.09
5.2.30.0080.0409.06
5.2.20.0040.0329.05
5.2.10.0070.0328.96
5.2.00.0100.0308.83
5.1.60.0040.0268.11
5.1.50.0060.0348.10
5.1.40.0050.0368.08
5.1.30.0040.0398.43
5.1.20.0070.0338.45
5.1.10.0060.0258.18
5.1.00.0030.0288.18
5.0.50.0040.0256.66
5.0.40.0050.0216.52
5.0.30.0070.0356.33
5.0.20.0040.0206.30
5.0.10.0070.0276.28
5.0.00.0040.0426.27
4.4.90.0050.0214.78
4.4.80.0060.0194.76
4.4.70.0020.0254.76
4.4.60.0090.0274.75
4.4.50.0080.0264.77
4.4.40.0030.0294.70
4.4.30.0060.0144.76
4.4.20.0030.0244.85
4.4.10.0050.0234.85
4.4.00.0030.0294.76
4.3.110.0050.0204.67
4.3.100.0060.0304.66
4.3.90.0120.0374.63
4.3.80.0050.0274.58
4.3.70.0010.0194.63
4.3.60.0040.0154.62
4.3.50.0040.0164.62
4.3.40.0030.0284.54
4.3.30.0040.0183.30
4.3.20.0020.0193.27
4.3.10.0010.0183.24
4.3.00.0130.01310.54

preferences:
45.47 ms | 401 KiB | 5 Q