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[$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.0120.00816.74
8.3.50.0090.00922.06
8.3.40.0070.01018.69
8.3.30.0150.00019.04
8.3.20.0080.00020.34
8.3.10.0060.00323.65
8.3.00.0060.00319.38
8.2.180.0040.01116.73
8.2.170.0090.00622.96
8.2.160.0040.01120.39
8.2.150.0090.00024.18
8.2.140.0030.00624.66
8.2.130.0110.00726.16
8.2.120.0090.00022.31
8.2.110.0000.00922.11
8.2.100.0060.00618.03
8.2.90.0080.00019.21
8.2.80.0030.00618.16
8.2.70.0090.00017.75
8.2.60.0040.00418.04
8.2.50.0070.00419.41
8.2.40.0000.00919.94
8.2.30.0050.00318.22
8.2.20.0050.00317.92
8.2.10.0000.00718.07
8.2.00.0070.00417.85
8.1.280.0150.00325.92
8.1.270.0090.00023.96
8.1.260.0060.00326.35
8.1.250.0030.00628.09
8.1.240.0000.01023.80
8.1.230.0000.01219.16
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0090.00017.38
8.1.190.0050.00317.66
8.1.180.0070.00319.13
8.1.170.0040.00418.70
8.1.160.0000.00822.05
8.1.150.0030.00618.59
8.1.140.0040.00417.41
8.1.130.0050.00317.87
8.1.120.0000.00717.41
8.1.110.0060.00317.40
8.1.100.0070.00017.51
8.1.90.0000.00717.52
8.1.80.0000.00717.40
8.1.70.0040.00417.33
8.1.60.0060.00617.62
8.1.50.0040.00417.57
8.1.40.0080.00017.56
8.1.30.0040.00417.60
8.1.20.0040.00417.67
8.1.10.0040.00417.47
8.1.00.0000.00817.57
8.0.300.0000.00918.77
8.0.290.0040.00417.05
8.0.280.0070.00018.45
8.0.270.0040.00417.24
8.0.260.0000.00717.28
8.0.250.0000.00717.03
8.0.240.0020.00516.98
8.0.230.0040.00416.96
8.0.220.0030.00316.92
8.0.210.0050.00317.00
8.0.200.0050.00216.94
8.0.190.0040.00417.02
8.0.180.0070.00016.89
8.0.170.0030.00516.92
8.0.160.0070.00016.91
8.0.150.0070.00016.84
8.0.140.0050.00316.98
8.0.130.0050.00013.30
8.0.120.0040.00416.90
8.0.110.0000.00716.91
8.0.100.0040.00416.88
8.0.90.0000.00716.89
8.0.80.0030.01417.05
8.0.70.0000.00816.94
8.0.60.0050.00316.95
8.0.50.0000.00816.87
8.0.30.0140.00817.24
8.0.20.0140.01017.40
8.0.10.0000.00817.05
8.0.00.0120.00816.77
7.4.330.0070.00015.00
7.4.320.0000.00716.68
7.4.300.0040.00416.64
7.4.290.0070.00016.61
7.4.280.0030.00516.64
7.4.270.0000.00816.69
7.4.260.0080.00016.61
7.4.250.0070.00316.64
7.4.240.0050.00216.48
7.4.230.0040.00416.33
7.4.220.0170.00416.66
7.4.210.0100.00816.53
7.4.200.0040.00416.63
7.4.190.0070.00016.64
7.4.160.0080.00816.46
7.4.150.0070.01017.40
7.4.140.0070.01017.86
7.4.130.0090.00916.52
7.4.120.0120.00516.67
7.4.110.0070.01016.56
7.4.100.0090.00916.57
7.4.90.0030.01416.41
7.4.80.0200.01019.39
7.4.70.0070.01016.62
7.4.60.0070.01116.45
7.4.50.0040.00416.46
7.4.40.0100.00622.77
7.4.30.0120.00416.68
7.4.00.0040.01215.02
7.3.330.0000.00713.29
7.3.320.0000.00513.50
7.3.310.0040.00416.51
7.3.300.0000.00716.48
7.3.290.0080.00816.43
7.3.280.0090.01116.45
7.3.270.0060.01217.40
7.3.260.0070.01016.55
7.3.250.0120.00916.54
7.3.240.0140.00716.66
7.3.230.0090.00616.65
7.3.210.0100.00716.38
7.3.200.0000.01616.50
7.3.190.0130.00716.53
7.3.180.0110.00716.79
7.3.170.0100.00716.54
7.3.160.0140.00316.58
7.3.120.0090.00614.96
7.3.110.0030.01315.00
7.3.100.0040.01214.98
7.3.90.0020.01114.97
7.3.80.0070.00514.99
7.3.70.0030.00914.92
7.3.60.0040.01014.94
7.3.50.0040.00814.96
7.3.40.0060.00814.84
7.3.30.0050.00814.89
7.3.20.0060.00716.61
7.3.10.0060.00716.60
7.3.00.0050.00916.74
7.2.330.0000.01816.82
7.2.320.0140.00316.53
7.2.310.0060.01116.81
7.2.300.0150.00316.77
7.2.290.0100.01016.48
7.2.250.0090.00815.23
7.2.240.0100.00715.25
7.2.230.0050.01214.87
7.2.220.0040.01015.11
7.2.210.0040.01115.08
7.2.200.0060.01015.11
7.2.190.0110.00615.04
7.2.180.0040.01015.18
7.2.170.0080.00615.07
7.2.160.0030.01315.20
7.2.150.0070.01017.03
7.2.140.0040.01416.84
7.2.130.0030.01517.12
7.2.120.0080.00317.14
7.2.110.0090.00617.06
7.2.100.0000.01317.06
7.2.90.0110.00417.17
7.2.80.0080.00416.82
7.2.70.0090.00616.97
7.2.60.0090.00417.06
7.2.50.0000.01717.10
7.2.40.0030.01316.96
7.2.30.0070.01017.09
7.2.20.0000.01116.79
7.2.10.0060.00916.79
7.2.00.0060.00917.09
7.1.330.0040.01016.07
7.1.320.0050.00815.78
7.1.310.0060.00915.89
7.1.300.0070.00715.78
7.1.290.0080.00615.82
7.1.280.0060.00715.76
7.1.270.0090.00515.80
7.1.260.0060.00815.66
7.1.250.0070.00716.04
7.1.200.0060.00916.05
7.1.70.0100.00317.28
7.1.60.0130.00319.46
7.1.50.0100.00316.92
7.1.00.0070.07322.51
7.0.200.1750.00314.80
7.0.140.0000.07721.95
7.0.60.0130.07319.89
7.0.50.0000.09017.90
7.0.40.0130.06720.29
7.0.30.0300.03720.07
7.0.20.0770.04320.19
7.0.10.0200.07720.09
7.0.00.0030.08020.05
5.6.280.0070.07021.16
5.6.210.0070.05320.52
5.6.200.0100.06318.20
5.6.190.0100.07320.42
5.6.180.0400.03320.43
5.6.170.0200.04320.39
5.6.160.0070.08720.71
5.6.150.0030.03718.18
5.6.140.0100.06318.24
5.6.130.0030.08018.28
5.6.120.0130.07721.13
5.6.110.0070.07720.99
5.6.100.0100.08020.98
5.6.90.0000.09020.89
5.6.80.0000.04720.41
5.5.350.0470.07020.32
5.5.340.0000.05317.99
5.5.330.0030.05720.43
5.5.320.0000.04320.31
5.5.310.0230.08720.32
5.5.300.0100.04017.97
5.5.290.0100.08017.98
5.5.280.0170.08020.98
5.5.270.0100.05020.87
5.5.260.0100.07020.87
5.5.250.0100.07720.69
5.5.240.0030.06720.38
5.4.450.0570.05719.38
5.4.440.0170.08719.71
5.4.430.0070.05719.43
5.4.420.0130.05319.52
5.4.410.0200.04319.33
5.4.400.0070.08019.39
5.4.390.0130.06019.05
5.4.380.0300.06018.78
5.4.370.0230.05718.74
5.4.360.0400.06718.78
5.4.350.0330.05018.54
5.4.340.0470.07018.66
5.4.320.0090.04112.52
5.4.310.0110.04212.51
5.4.300.0060.04612.51
5.4.290.0100.05212.49
5.4.280.0070.05212.39
5.4.270.0070.05112.39
5.4.260.0130.04312.39
5.4.250.0060.04312.39
5.4.240.0100.03712.39
5.4.230.0080.04512.38
5.4.220.0120.04612.38
5.4.210.0100.06112.39
5.4.200.0040.04712.38
5.4.190.0060.04012.38
5.4.180.0080.03912.38
5.4.170.0070.04812.38
5.4.160.0050.04412.38
5.4.150.0100.03612.37
5.4.140.0070.03912.06
5.4.130.0080.03612.04
5.4.120.0060.03812.00
5.4.110.0080.04612.00
5.4.100.0080.06812.00
5.4.90.0090.05112.00
5.4.80.0160.06112.00
5.4.70.0060.05512.00
5.4.60.0080.05312.00
5.4.50.0080.05312.00
5.4.40.0050.05611.98
5.4.30.0190.07211.98
5.4.20.0090.05111.98
5.4.10.0090.07311.98
5.4.00.0120.04011.48
5.3.290.0050.04212.80
5.3.280.0070.05112.71
5.3.270.0130.03812.72
5.3.260.0100.05012.72
5.3.250.0110.05012.72
5.3.240.0100.03712.72
5.3.230.0060.04112.71
5.3.220.0070.04412.68
5.3.210.0180.08112.68
5.3.200.0200.07212.68
5.3.190.0210.07112.68
5.3.180.0180.06512.67
5.3.170.0120.05512.67
5.3.160.0130.08112.67
5.3.150.0090.07212.68
5.3.140.0110.06112.66
5.3.130.0100.06312.66
5.3.120.0100.05412.66
5.3.110.0130.08212.66
5.3.100.0050.07212.13
5.3.90.0060.05612.11
5.3.80.0080.04912.11
5.3.70.0080.05312.11
5.3.60.0070.05512.09
5.3.50.0060.05212.04
5.3.40.0090.04912.04
5.3.30.0060.05212.00
5.3.20.0080.04711.78
5.3.10.0110.04811.74
5.3.00.0120.08211.73
5.2.170.0080.0499.24
5.2.160.0070.0469.23
5.2.150.0030.0469.24
5.2.140.0040.0339.23
5.2.130.0050.0319.20
5.2.120.0040.0319.19
5.2.110.0060.0309.20
5.2.100.0090.0469.20
5.2.90.0070.0299.19
5.2.80.0100.0529.19
5.2.70.0080.0349.19
5.2.60.0050.0549.14
5.2.50.0060.0539.11
5.2.40.0070.0549.09
5.2.30.0050.0499.07
5.2.20.0100.0399.05
5.2.10.0060.0448.96
5.2.00.0080.0558.82
5.1.60.0070.0508.11
5.1.50.0150.0338.10
5.1.40.0080.0418.08
5.1.30.0060.0418.43
5.1.20.0060.0418.45
5.1.10.0160.0518.18
5.1.00.0040.0388.18
5.0.50.0070.0266.67
5.0.40.0060.0276.52
5.0.30.0070.0426.33
5.0.20.0070.0256.30
5.0.10.0050.0276.28
5.0.00.0050.0426.27
4.4.90.0060.0204.78
4.4.80.0040.0314.76
4.4.70.0120.0324.76
4.4.60.0070.0394.75
4.4.50.0070.0394.77
4.4.40.0040.0354.71
4.4.30.0060.0204.76
4.4.20.0040.0214.84
4.4.10.0060.0234.85
4.4.00.0040.0334.75
4.3.110.0050.0294.67
4.3.100.0040.0244.66
4.3.90.0030.0244.64
4.3.80.0040.0364.58
4.3.70.0020.0254.63
4.3.60.0050.0224.63
4.3.50.0060.0244.63
4.3.40.0060.0334.53
4.3.30.0050.0253.30
4.3.20.0010.0243.28
4.3.10.0020.0223.24
4.3.00.0100.0136.92

preferences:
57.91 ms | 401 KiB | 5 Q