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 print_r('key:::::'.$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.0070.01016.59
8.3.50.0120.00622.01
8.3.40.0070.01118.67
8.3.30.0070.00719.18
8.3.20.0090.00020.34
8.3.10.0080.00023.65
8.3.00.0030.00519.38
8.2.180.0090.01217.00
8.2.170.0090.00622.96
8.2.160.0110.00720.52
8.2.150.0030.00624.18
8.2.140.0070.00024.66
8.2.130.0110.00326.16
8.2.120.0070.00022.21
8.2.110.0030.00622.27
8.2.100.0040.00817.97
8.2.90.0040.00419.30
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0070.00017.93
8.2.50.0050.00318.07
8.2.40.0000.00820.07
8.2.30.0060.00318.08
8.2.20.0040.00417.86
8.2.10.0000.00818.20
8.2.00.0030.00617.71
8.1.280.0110.00725.92
8.1.270.0050.00322.20
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.00823.64
8.1.230.0000.01118.82
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.01017.35
8.1.190.0060.00317.52
8.1.180.0030.00618.10
8.1.170.0060.00318.55
8.1.160.0040.00421.94
8.1.150.0100.00018.57
8.1.140.0040.00417.47
8.1.130.0070.00017.77
8.1.120.0070.00017.52
8.1.110.0040.00417.52
8.1.100.0000.00717.39
8.1.90.0000.00717.34
8.1.80.0000.00717.47
8.1.70.0060.00317.41
8.1.60.0060.00317.59
8.1.50.0000.00817.50
8.1.40.0040.00417.51
8.1.30.0000.00817.50
8.1.20.0080.00017.59
8.1.10.0030.00617.50
8.1.00.0040.00417.54
8.0.300.0000.00820.73
8.0.290.0000.00717.18
8.0.280.0000.00718.46
8.0.270.0000.00717.19
8.0.260.0070.00017.24
8.0.250.0040.00417.05
8.0.240.0000.00717.00
8.0.230.0030.00316.92
8.0.220.0000.00717.05
8.0.210.0030.00416.94
8.0.200.0030.00316.93
8.0.190.0020.00516.90
8.0.180.0000.00817.04
8.0.170.0020.00517.02
8.0.160.0040.00416.92
8.0.150.0030.00316.91
8.0.140.0040.00416.93
8.0.130.0070.00013.39
8.0.120.0070.00016.84
8.0.110.0000.00816.93
8.0.100.0000.00716.86
8.0.90.0030.00416.97
8.0.80.0080.00816.95
8.0.70.0000.00717.02
8.0.60.0050.00316.78
8.0.50.0000.00716.98
8.0.30.0120.00717.39
8.0.20.0090.00917.40
8.0.10.0000.00817.21
8.0.00.0100.00716.74
7.4.330.0000.00515.00
7.4.320.0030.00316.53
7.4.300.0030.00316.53
7.4.290.0030.00316.43
7.4.280.0030.00316.53
7.4.270.0000.00716.53
7.4.260.0030.00316.47
7.4.250.0080.00016.49
7.4.240.0020.00516.54
7.4.230.0030.00316.42
7.4.220.0120.01516.43
7.4.210.0100.00916.61
7.4.200.0030.00316.65
7.4.190.0000.00716.72
7.4.160.0090.00616.62
7.4.150.0060.01217.40
7.4.140.0100.01417.86
7.4.130.0070.01016.60
7.4.120.0090.01016.58
7.4.110.0130.00316.60
7.4.100.0080.01116.52
7.4.90.0090.00816.54
7.4.80.0090.01719.39
7.4.70.0060.01216.53
7.4.60.0120.01216.60
7.4.50.0060.00316.45
7.4.40.0060.00922.77
7.4.30.0060.00916.58
7.4.00.0080.00814.95
7.3.330.0050.00013.30
7.3.320.0030.00313.53
7.3.310.0080.00016.27
7.3.300.0000.00716.38
7.3.290.0030.01216.53
7.3.280.0110.00916.41
7.3.270.0130.00717.40
7.3.260.0150.00916.80
7.3.250.0110.01216.44
7.3.240.0130.00416.66
7.3.230.0120.00416.39
7.3.210.0060.01216.44
7.3.200.0070.01016.65
7.3.190.0120.00916.53
7.3.180.0030.01416.80
7.3.170.0090.00616.48
7.3.160.0060.01016.54
7.3.120.0000.01515.01
7.3.00.0100.00716.40
7.2.330.0140.00616.78
7.2.320.0070.01016.92
7.2.310.0060.01116.88
7.2.300.0070.01016.88
7.2.290.0090.00916.61
7.2.130.0040.00816.82
7.2.120.0110.00616.65
7.2.110.0090.00516.85
7.2.100.0090.00416.74
7.2.90.0100.01016.56
7.2.80.0060.01016.60
7.2.70.0110.00616.96
7.2.60.0090.00516.63
7.2.50.0100.00516.93
7.2.40.0120.00416.89
7.2.30.0100.00716.95
7.2.20.0080.00916.79
7.2.10.0040.01216.92
7.2.00.0090.00517.80
7.1.250.0120.00015.67
7.1.240.0100.00715.84
7.1.230.0110.00615.89
7.1.220.0090.00715.73
7.1.210.0140.00415.71
7.1.200.0140.00415.71
7.1.190.0090.00715.62
7.1.180.0080.00915.73
7.1.170.0100.00515.75
7.1.160.0100.00515.76
7.1.150.0070.01015.51
7.1.140.0080.00615.61
7.1.130.0110.00415.61
7.1.120.0090.00515.80
7.1.110.0060.00615.86
7.1.100.0090.00616.38
7.1.90.0140.00315.77
7.1.80.0130.00415.57
7.1.70.0060.00716.28
7.1.60.0070.00816.94
7.1.50.0100.00516.12
7.1.40.0100.00315.63
7.1.30.0090.00615.66
7.1.20.0070.00515.67
7.1.10.0050.01115.51
7.1.00.0070.03117.87
7.0.330.0070.00715.24
7.0.320.0080.00515.19
7.0.310.0070.00915.31
7.0.300.0100.00815.17
7.0.290.0070.00615.33
7.0.280.0130.00415.25
7.0.270.0060.00815.30
7.0.260.0070.00815.23
7.0.250.0070.00815.21
7.0.240.0060.00815.48
7.0.230.0060.01015.21
7.0.220.0230.00315.38
7.0.210.0100.00515.35
7.0.200.0240.00515.87
7.0.190.0110.00515.22
7.0.180.0090.00915.33
7.0.170.0110.00515.29
7.0.160.0100.00415.26
7.0.150.0050.00915.38
7.0.140.0080.02617.50
7.0.130.0070.00715.38
7.0.120.0090.00515.49
7.0.110.0110.00615.30
7.0.100.0100.00315.25
7.0.90.0100.00515.41
7.0.80.0110.00215.38
7.0.70.0240.00515.21
7.0.60.0100.01816.75
7.0.50.0090.02816.25
7.0.40.0040.03215.70
7.0.30.0150.02115.55
7.0.20.0120.02515.58
7.0.10.0090.02015.59
7.0.00.0060.03315.68
5.6.380.0050.00814.61
5.6.370.0100.00214.59
5.6.360.0090.00314.31
5.6.350.0080.00814.36
5.6.340.0060.00614.35
5.6.330.0090.00514.47
5.6.320.0100.00814.46
5.6.310.0040.01014.62
5.6.300.0090.00614.53
5.6.290.0100.00314.30
5.6.280.0060.02816.49
5.6.270.0070.00714.31
5.6.260.0060.00714.42
5.6.250.0080.00514.32
5.6.240.0060.00914.39
5.6.230.0050.00914.30
5.6.220.0060.00714.11
5.6.210.0060.03316.41
5.6.200.0110.01215.54
5.6.190.0010.03016.45
5.6.180.1280.02016.46
5.6.170.0120.01616.33
5.6.160.0040.01916.39
5.6.150.0060.02315.68
5.6.140.0100.02815.50
5.6.130.0090.03115.72
5.6.120.0110.02216.50
5.6.110.0030.03716.57
5.6.100.0120.02816.59
5.6.90.0040.03716.58
5.6.80.0090.02016.39
5.6.70.1550.01716.35
5.6.60.0060.00814.43
5.6.50.0060.00514.35
5.6.40.0070.00714.30
5.6.30.0020.01014.14
5.6.20.0110.00314.28
5.6.10.0080.00614.27
5.6.00.0050.00814.21
5.5.380.0020.01011.37
5.5.370.0100.00011.21
5.5.360.0010.00611.35
5.5.350.0060.01314.33
5.5.340.0070.02813.56
5.5.330.0060.01714.13
5.5.320.0120.02214.25
5.5.310.0180.02614.19
5.5.300.0060.02613.52
5.5.290.0060.02213.50
5.5.280.0080.03014.56
5.5.270.0090.02214.60
5.5.260.0060.01714.50
5.5.250.0060.02114.31
5.5.240.0140.02314.23
5.5.230.0080.00511.16
5.5.220.0070.00511.24
5.5.210.0070.00211.22
5.5.200.0090.00511.14
5.5.190.0070.00511.20
5.5.180.0140.00011.27
5.5.170.0070.00512.66
5.5.160.0060.00511.24
5.5.150.0040.00711.08
5.5.140.0080.00511.33
5.5.130.0060.00611.22
5.5.120.0090.00511.23
5.5.110.0070.00711.30
5.5.100.0060.00511.15
5.5.90.0080.00511.21
5.5.80.0100.00311.27
5.5.70.0080.00711.20
5.5.60.0100.00311.31
5.5.50.0060.00711.24
5.5.40.0100.00410.96
5.5.30.0050.00911.27
5.5.20.0060.00710.95
5.5.10.0030.00911.28
5.5.00.0090.00311.11
5.4.450.0260.02314.02
5.4.440.0290.02613.95
5.4.430.0110.02013.95
5.4.420.0330.02013.94
5.4.410.0270.02814.01
5.4.400.0150.02113.88
5.4.390.0180.02213.96
5.4.380.0140.02013.67
5.4.370.0140.02413.71
5.4.360.0190.01513.58
5.4.350.0170.01913.60
5.4.340.0230.02013.59
5.4.330.0080.00511.19
5.4.320.0070.01911.64
5.4.310.0040.02211.54
5.4.300.0060.01911.57
5.4.290.0070.01911.72
5.4.280.0110.02411.71
5.4.270.0080.02011.60
5.4.260.0060.02911.45
5.4.250.0100.01411.60
5.4.240.0080.01611.55
5.4.230.0080.02211.58
5.4.220.0080.02111.55
5.4.210.0080.01711.56
5.4.200.0090.01611.57
5.4.190.0100.01711.52
5.4.180.0080.02911.61
5.4.170.0100.01811.60
5.4.160.0130.01411.49
5.4.150.0090.01611.58
5.4.140.0060.01811.50
5.4.130.0080.01711.59
5.4.120.0100.01511.55
5.4.110.0060.02711.53
5.4.100.0100.02411.54
5.4.90.0070.03011.38
5.4.80.0050.02211.53
5.4.70.0080.01411.42
5.4.60.0060.01611.40
5.4.50.0070.01511.51
5.4.40.0060.01711.41
5.4.30.0050.02211.41
5.4.20.0110.01811.45
5.4.10.0080.01811.39
5.4.00.0040.02411.23
5.3.290.0090.01611.59
5.3.280.0080.02011.49
5.3.270.0070.01611.54
5.3.260.0090.02011.53
5.3.250.0050.02411.48
5.3.240.0110.01611.44
5.3.230.0070.01811.51
5.3.220.0070.01711.51
5.3.210.0050.01811.48
5.3.200.0060.01511.49
5.3.190.0060.01611.50
5.3.180.0050.01811.56
5.3.170.0050.01811.54
5.3.160.0080.01311.59
5.3.150.0070.01411.59
5.3.140.0060.01511.52
5.3.130.0090.02011.46
5.3.120.0050.01811.45
5.3.110.0060.02211.43
5.3.100.0020.01811.33
5.3.90.0050.01811.29
5.3.80.0100.01211.34
5.3.70.0070.01511.30
5.3.60.0070.01511.29
5.3.50.0060.01711.28
5.3.40.0060.02111.29
5.3.30.0060.01711.27
5.3.20.0050.01711.18
5.3.10.0050.02211.11
5.3.00.0080.01511.12
5.2.170.0060.01410.02
5.2.160.0050.01410.00
5.2.150.0030.01510.03
5.2.140.0050.01310.00
5.2.130.0030.0179.98
5.2.120.0050.0129.91
5.2.110.0040.0149.88
5.2.100.0040.01610.00
5.2.90.0050.01510.02
5.2.80.0050.0179.96
5.2.70.0040.0149.94
5.2.60.0050.0159.84
5.2.50.0060.0119.88
5.2.40.0040.0169.93
5.2.30.0070.0139.85
5.2.20.0060.0149.85
5.2.10.0050.0169.68
5.2.00.0070.0189.78
5.1.60.0060.0159.27
5.1.50.0050.0149.29
5.1.40.0060.0139.22
5.1.30.0050.0179.45
5.1.20.0050.0129.36
5.1.10.0040.0109.34
5.1.00.0050.0109.31
5.0.50.0060.0118.69
5.0.40.0070.0108.64
5.0.30.0010.0178.58
5.0.20.0020.0118.57
5.0.10.0060.0068.56
5.0.00.0050.0148.56
4.4.90.0060.0118.06
4.4.80.0030.0088.06
4.4.70.0020.0128.05
4.4.60.0020.0118.05
4.4.50.0030.0118.06
4.4.40.0020.0148.04
4.4.30.0040.0078.06
4.4.20.0030.0078.09
4.4.10.0030.0088.09
4.4.00.0020.0128.06
4.3.110.0010.0118.02
4.3.100.0010.0098.03
4.3.90.0030.0078.01
4.3.80.0020.0128.00
4.3.70.0040.0088.01
4.3.60.0050.0068.01
4.3.50.0050.0058.01
4.3.40.0030.0107.98
4.3.30.0030.0087.57
4.3.20.0010.0087.56
4.3.10.0020.0087.55
4.3.00.0100.0139.98

preferences:
35.74 ms | 401 KiB | 5 Q