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 , $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.0140.00416.75
8.3.50.0120.00821.95
8.3.40.0070.01018.97
8.3.30.0090.00619.07
8.3.20.0040.00420.29
8.3.10.0080.00023.58
8.3.00.0040.00419.38
8.2.180.0130.00618.42
8.2.170.0070.00722.96
8.2.160.0070.00720.35
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0040.00422.26
8.2.110.0060.00322.16
8.2.100.0080.00317.91
8.2.90.0040.00418.03
8.2.80.0030.00717.97
8.2.70.0000.00917.63
8.2.60.0000.00818.03
8.2.50.0040.00418.07
8.2.40.0040.00420.07
8.2.30.0080.00018.05
8.2.20.0040.00417.85
8.2.10.0040.00418.23
8.2.00.0040.00417.90
8.1.280.0180.00025.92
8.1.270.0040.00423.97
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00322.48
8.1.230.0080.00420.97
8.1.220.0060.00317.79
8.1.210.0000.00818.88
8.1.200.0090.00017.21
8.1.190.0060.00317.53
8.1.180.0060.00318.10
8.1.170.0030.00618.57
8.1.160.0070.00021.97
8.1.150.0030.00718.59
8.1.140.0070.00017.39
8.1.130.0000.00717.77
8.1.120.0040.00417.50
8.1.110.0000.01017.56
8.1.100.0000.00717.34
8.1.90.0000.00717.53
8.1.80.0020.00517.43
8.1.70.0030.00317.45
8.1.60.0050.00317.66
8.1.50.0040.00417.48
8.1.40.0080.00017.47
8.1.30.0080.00017.57
8.1.20.0000.00717.69
8.1.10.0000.00817.57
8.1.00.0000.00817.44
8.0.300.0040.00420.15
8.0.290.0070.00017.18
8.0.280.0050.00218.49
8.0.270.0030.00317.18
8.0.260.0030.00317.23
8.0.250.0050.00317.00
8.0.240.0000.00816.98
8.0.230.0040.00417.07
8.0.220.0000.00717.07
8.0.210.0070.00016.89
8.0.200.0030.00316.95
8.0.190.0060.00317.02
8.0.180.0000.00716.98
8.0.170.0050.00317.02
8.0.160.0040.00416.96
8.0.150.0040.00416.94
8.0.140.0000.00716.96
8.0.130.0000.00613.46
8.0.120.0050.00316.91
8.0.110.0000.00816.91
8.0.100.0080.00017.02
8.0.90.0000.00816.95
8.0.80.0100.01016.99
8.0.70.0040.00416.91
8.0.60.0040.00416.95
8.0.50.0070.00016.97
8.0.30.0130.00717.33
8.0.20.0080.01017.40
8.0.10.0000.00717.00
8.0.00.0090.00916.96
7.4.330.0030.00315.00
7.4.320.0000.00716.46
7.4.300.0030.00316.64
7.4.290.0000.00716.63
7.4.280.0000.00716.58
7.4.270.0030.00316.55
7.4.260.0040.00416.49
7.4.250.0040.00416.41
7.4.240.0050.00216.67
7.4.230.0070.00016.59
7.4.220.0160.00016.49
7.4.210.0050.00916.53
7.4.200.0070.00016.68
7.4.190.0000.00716.73
7.4.160.0080.00816.58
7.4.150.0090.00917.40
7.4.140.0110.00817.86
7.4.130.0080.01316.68
7.4.120.0130.00516.57
7.4.110.0100.00716.65
7.4.100.0110.00716.50
7.4.90.0090.00916.66
7.4.80.0070.01119.39
7.4.70.0130.01016.52
7.4.60.0030.01216.33
7.4.50.0050.00316.68
7.4.40.0040.01122.77
7.4.30.0070.01016.63
7.4.00.0030.01415.07
7.3.330.0060.00013.46
7.3.320.0000.00513.43
7.3.310.0050.00216.38
7.3.300.0040.00416.39
7.3.290.0080.01216.43
7.3.280.0090.00916.45
7.3.270.0030.01317.40
7.3.260.0050.01316.47
7.3.250.0120.00816.59
7.3.240.0110.00616.63
7.3.230.0150.00916.39
7.3.210.0030.01716.50
7.3.200.0110.00819.39
7.3.190.0000.01516.45
7.3.180.0040.01816.69
7.3.170.0090.01216.64
7.3.160.0060.01116.39
7.3.120.0080.00814.90
7.2.330.0100.00716.84
7.2.320.0090.00916.58
7.2.310.0110.00616.73
7.2.300.0100.00716.55
7.2.290.0080.00816.77
7.2.110.0080.01616.70
7.2.100.0260.00016.73
7.2.90.0200.01016.50
7.2.80.0260.00316.80
7.2.70.0230.01017.00
7.2.60.0120.01116.79
7.2.50.0250.00516.92
7.2.40.0230.00916.96
7.2.30.0190.01016.71
7.2.20.0160.01316.91
7.2.10.0250.00616.74
7.2.00.0130.00317.00
7.1.230.0170.00915.91
7.1.220.0160.00815.61
7.1.210.0170.01015.62
7.1.200.0160.00615.90
7.1.190.0180.00915.82
7.1.180.0200.00815.48
7.1.170.0200.00915.64
7.1.160.0180.00715.80
7.1.150.0190.00815.79
7.1.140.0150.01015.84
7.1.130.0230.00315.93
7.1.120.0140.01115.68
7.1.110.0200.00315.68
7.1.100.0220.00215.75
7.1.90.0030.01015.67
7.1.80.0040.01115.83
7.1.70.0050.00616.38
7.1.60.0100.01217.71
7.1.50.0070.01216.35
7.1.40.0040.01115.96
7.1.30.0070.01115.80
7.1.20.0060.01015.73
7.1.10.0140.00015.72
7.1.00.0050.04319.03
7.0.310.0180.01115.50
7.0.300.0160.00815.11
7.0.290.0140.01115.23
7.0.280.0120.01115.18
7.0.270.0160.00815.43
7.0.260.0130.01115.41
7.0.250.0090.01315.52
7.0.240.0060.00915.45
7.0.230.0030.01015.37
7.0.220.0030.00615.28
7.0.210.0030.01015.21
7.0.200.0050.00716.07
7.0.190.0040.00815.33
7.0.180.0080.00815.29
7.0.170.0060.00615.48
7.0.160.0100.00615.32
7.0.150.0060.01015.46
7.0.140.0020.04318.64
7.0.130.0040.01215.31
7.0.120.0000.01215.63
7.0.110.0040.01215.24
7.0.100.0070.00715.10
7.0.90.0040.01115.18
7.0.80.0040.00815.25
7.0.70.0030.01015.36
7.0.60.0050.04717.53
7.0.50.0080.03816.56
7.0.40.0080.04516.77
7.0.30.0280.03916.90
7.0.20.0180.02816.71
7.0.10.0070.02816.75
7.0.00.0090.02716.78
5.6.380.0150.01114.50
5.6.370.0090.01414.45
5.6.360.0130.01314.77
5.6.350.0220.00314.60
5.6.340.0210.00414.68
5.6.330.0210.00014.71
5.6.320.0120.01514.45
5.6.310.0000.01614.74
5.6.300.0110.00714.27
5.6.290.0100.00614.21
5.6.280.0040.04117.47
5.6.270.0040.01114.36
5.6.260.0070.01014.36
5.6.250.0100.00513.95
5.6.240.0040.01114.18
5.6.230.0070.01013.80
5.6.220.0000.01614.18
5.6.210.0090.03917.44
5.6.200.0020.03516.29
5.6.190.0100.04717.35
5.6.180.0150.02117.47
5.6.170.0160.03517.49
5.6.160.0040.04917.33
5.6.150.0060.04716.20
5.6.140.0080.04216.33
5.6.130.0050.04516.20
5.6.120.0060.04817.70
5.6.110.0090.04617.82
5.6.100.0180.04017.67
5.6.90.0090.04317.72
5.6.80.0070.03817.32
5.6.70.0300.02517.12
5.6.60.0080.00814.04
5.6.50.0030.01113.84
5.6.40.0100.00314.13
5.6.30.0080.00414.23
5.6.20.0070.00714.26
5.6.10.0110.00014.14
5.6.00.0070.00713.98
5.5.380.0040.00710.98
5.5.370.0110.00011.16
5.5.360.0050.00511.18
5.5.350.0140.01515.72
5.5.340.0070.02014.62
5.5.330.0140.03615.64
5.5.320.0160.02515.60
5.5.310.0210.04215.72
5.5.300.0060.04414.59
5.5.290.0100.02414.60
5.5.280.0060.04916.14
5.5.270.0050.02315.99
5.5.260.0120.02415.68
5.5.250.0070.04515.81
5.5.240.1320.02315.66
5.5.230.0080.00410.91
5.5.220.0070.00210.76
5.5.210.0000.01311.05
5.5.200.0080.00410.67
5.5.190.0030.00611.07
5.5.180.0050.00510.78
5.5.170.0130.00314.09
5.5.160.0060.00610.95
5.5.150.0040.00711.19
5.5.140.0030.00911.07
5.5.130.0060.00611.16
5.5.120.0040.00811.43
5.5.110.0080.00411.31
5.5.100.0040.00710.93
5.5.90.0040.00411.20
5.5.80.0060.00611.23
5.5.70.0000.00911.07
5.5.60.0040.00711.24
5.5.50.0120.00010.74
5.5.40.0040.00410.94
5.5.30.0030.00711.14
5.5.20.0040.00811.16
5.5.10.0040.00811.09
5.5.00.0040.00810.74
5.4.450.0380.03615.09
5.4.440.0440.03415.31
5.4.430.0230.03315.24
5.4.420.0400.03115.46
5.4.410.0380.02715.17
5.4.400.0090.02814.94
5.4.390.0390.03315.11
5.4.380.0130.03314.94
5.4.370.0290.03114.91
5.4.360.0230.02314.77
5.4.350.0220.03914.80
5.4.340.0320.03314.72
5.4.330.0060.00610.91
5.4.320.0040.02511.76
5.4.310.0060.02411.69
5.4.300.0020.02711.69
5.4.290.0050.02411.66
5.4.280.0100.02011.83
5.4.270.0040.02711.51
5.4.260.0050.02511.73
5.4.250.0050.02411.67
5.4.240.0060.02911.84
5.4.230.0040.02811.74
5.4.220.0050.02311.52
5.4.210.0060.02211.46
5.4.200.0100.02111.63
5.4.190.0080.02211.73
5.4.180.0110.02411.72
5.4.170.0060.03011.65
5.4.160.0060.02911.60
5.4.150.0040.03011.42
5.4.140.0060.03011.40
5.4.130.0050.02411.52
5.4.120.0080.02911.57
5.4.110.0060.02211.48
5.4.100.0070.02211.55
5.4.90.0050.02611.41
5.4.80.0070.02911.39
5.4.70.0050.02211.30
5.4.60.0090.03511.54
5.4.50.0050.02511.60
5.4.40.0060.03011.46
5.4.30.0040.02411.41
5.4.20.0060.02611.52
5.4.10.0050.02811.37
5.4.00.0110.02311.04
5.3.290.0070.02711.80
5.3.280.0070.02411.58
5.3.270.0040.02411.72
5.3.260.0040.03011.68
5.3.250.0080.02911.70
5.3.240.0070.02711.53
5.3.230.0050.04011.61
5.3.220.0070.02811.54
5.3.210.0100.03811.62
5.3.200.0100.03711.72
5.3.190.0080.03811.65
5.3.180.0050.03611.78
5.3.170.0100.04711.80
5.3.160.0090.02811.59
5.3.150.0180.06711.78
5.3.140.0110.04111.68
5.3.130.0090.03111.64
5.3.120.0070.03311.70
5.3.110.0080.02211.59
5.3.100.0060.02111.29
5.3.90.0040.02211.29
5.3.80.0080.02111.42
5.3.70.0060.03211.22
5.3.60.0080.02611.38
5.3.50.0070.02911.29
5.3.40.0070.02711.35
5.3.30.0040.02711.24
5.3.20.0030.03111.06
5.3.10.0070.02911.09
5.3.00.0060.02911.12
5.2.170.0040.0209.32
5.2.160.0040.0209.37
5.2.150.0040.0209.46
5.2.140.0020.0219.29
5.2.130.0030.0219.26
5.2.120.0040.0209.32
5.2.110.0080.0179.37
5.2.100.0070.0159.35
5.2.90.0060.0179.38
5.2.80.0050.0199.37
5.2.70.0080.0229.41
5.2.60.0070.0179.28
5.2.50.0020.0239.37
5.2.40.0050.0249.31
5.2.30.0060.0309.25
5.2.20.0070.0229.21
5.2.10.0050.0229.03
5.2.00.0080.0329.02
5.1.60.0050.0228.38
5.1.50.0060.0178.31
5.1.40.0040.0158.40
5.1.30.0050.0218.61
5.1.20.0050.0278.57
5.1.10.0070.0198.28
5.1.00.0060.0198.38
5.0.50.0080.0227.31
5.0.40.0050.0197.24
5.0.30.0100.0257.15
5.0.20.0070.0167.13
5.0.10.0050.0167.12
5.0.00.0060.0517.12
4.4.90.0080.0226.37
4.4.80.0060.0216.36
4.4.70.0040.0106.36
4.4.60.0020.0136.36
4.4.50.0050.0136.37
4.4.40.0050.0236.33
4.4.30.0040.0106.36
4.4.20.0040.0126.40
4.4.10.0100.0236.41
4.4.00.0040.0206.36
4.3.110.0080.0206.32
4.3.100.0060.0236.31
4.3.90.0020.0176.30
4.3.80.0030.0236.27
4.3.70.0020.0126.30
4.3.60.0030.0136.29
4.3.50.0040.0126.30
4.3.40.0010.0326.25
4.3.30.0020.0135.63
4.3.20.0020.0125.62
4.3.10.0040.0095.60
4.3.00.0100.0069.25

preferences:
33.03 ms | 401 KiB | 5 Q