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.0100.00316.75
8.3.50.0130.00821.95
8.3.40.0200.00018.98
8.3.30.0040.01119.20
8.3.20.0040.00420.29
8.3.10.0050.00323.84
8.3.00.0050.00319.50
8.2.180.0110.00418.29
8.2.170.0040.01122.96
8.2.160.0150.00620.21
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0120.00626.16
8.2.120.0040.00422.25
8.2.110.0060.00321.17
8.2.100.0030.00918.09
8.2.90.0080.00019.34
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0000.00818.05
8.2.50.0030.00518.07
8.2.40.0000.00820.01
8.2.30.0040.00418.21
8.2.20.0000.00817.72
8.2.10.0060.00318.05
8.2.00.0040.00717.84
8.1.280.0140.00325.92
8.1.270.0050.00324.01
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00319.13
8.1.230.0070.00319.12
8.1.220.0000.00817.78
8.1.210.0000.00918.77
8.1.200.0000.00917.35
8.1.190.0000.00917.53
8.1.180.0040.00418.10
8.1.170.0080.00018.50
8.1.160.0040.00422.14
8.1.150.0060.00318.66
8.1.140.0040.00417.46
8.1.130.0000.00817.81
8.1.120.0040.00417.56
8.1.110.0030.00717.52
8.1.100.0000.00717.48
8.1.90.0000.00717.38
8.1.80.0070.00017.48
8.1.70.0070.00017.45
8.1.60.0030.00617.63
8.1.50.0000.00817.54
8.1.40.0060.00317.53
8.1.30.0040.00417.63
8.1.20.0030.00617.57
8.1.10.0030.00617.48
8.1.00.0020.00517.55
8.0.300.0000.00720.70
8.0.290.0030.00617.16
8.0.280.0000.00718.43
8.0.270.0070.00017.33
8.0.260.0030.00317.30
8.0.250.0030.00317.09
8.0.240.0030.00617.06
8.0.230.0000.00716.98
8.0.220.0030.00316.87
8.0.210.0030.00316.87
8.0.200.0000.00617.05
8.0.190.0030.00616.92
8.0.180.0040.00416.96
8.0.170.0040.00417.02
8.0.160.0000.00816.93
8.0.150.0000.00716.80
8.0.140.0000.00716.94
8.0.130.0000.00613.48
8.0.120.0080.00016.98
8.0.110.0040.00416.82
8.0.100.0000.00816.78
8.0.90.0000.00716.84
8.0.80.0100.01017.02
8.0.70.0050.00217.11
8.0.60.0050.00317.06
8.0.50.0000.00717.10
8.0.30.0040.01717.00
8.0.20.0080.01017.40
8.0.10.0040.00417.17
8.0.00.0120.00616.81
7.4.330.0000.00615.00
7.4.320.0030.00416.52
7.4.300.0000.00616.64
7.4.290.0030.00316.44
7.4.280.0040.00416.63
7.4.270.0000.00716.68
7.4.260.0030.00316.55
7.4.250.0000.00816.51
7.4.240.0060.00116.57
7.4.230.0030.00316.71
7.4.220.0030.01516.54
7.4.210.0100.00716.60
7.4.200.0000.00816.57
7.4.190.0000.00716.63
7.4.160.0080.00816.65
7.4.150.0090.01017.40
7.4.140.0100.01017.86
7.4.130.0100.00716.48
7.4.120.0080.00916.56
7.4.110.0070.01116.57
7.4.100.0100.01016.60
7.4.90.0090.00916.57
7.4.80.0040.01419.39
7.4.70.0000.02016.45
7.4.60.0140.00716.54
7.4.50.0080.00016.71
7.4.40.0030.01422.77
7.4.30.0140.00316.54
7.4.00.0040.01115.18
7.3.330.0030.00313.34
7.3.320.0060.00013.30
7.3.310.0000.00816.29
7.3.300.0040.00416.43
7.3.290.0090.00916.50
7.3.280.0060.01116.43
7.3.270.0070.01017.40
7.3.260.0170.00716.63
7.3.250.0080.01216.53
7.3.240.0120.00316.58
7.3.230.0070.01016.49
7.3.210.0120.00616.57
7.3.200.0130.00316.42
7.3.190.0060.01116.36
7.3.180.0170.00416.69
7.3.170.0080.01416.46
7.3.160.0060.01016.34
7.3.120.0040.01114.95
7.3.10.0140.00416.36
7.3.00.0150.00216.35
7.2.330.0140.00416.52
7.2.320.0100.01316.59
7.2.310.0190.00316.43
7.2.300.0070.01016.91
7.2.290.0130.00616.79
7.2.130.0170.00517.06
7.2.120.0070.00816.58
7.2.110.0080.01016.68
7.2.100.0120.00616.45
7.2.90.0110.00716.66
7.2.80.0090.00916.46
7.2.70.0130.00916.52
7.2.60.0170.00916.45
7.2.50.0110.00516.62
7.2.40.0150.00616.59
7.2.30.0100.00816.47
7.2.20.0110.00816.51
7.2.10.0090.00716.31
7.2.00.0090.01017.72
7.1.250.0090.01015.51
7.1.240.0050.00515.57
7.1.230.0040.01115.55
7.1.220.0030.00615.93
7.1.210.0070.01015.91
7.1.200.0070.00615.74
7.1.190.0090.00915.82
7.1.180.0120.00015.48
7.1.170.0060.00615.92
7.1.160.0090.00015.80
7.1.150.0030.01015.54
7.1.140.0040.01115.85
7.1.130.0100.00315.60
7.1.120.0060.00615.79
7.1.110.0090.00615.89
7.1.100.0030.00616.98
7.1.90.0090.00615.70
7.1.80.0030.01016.00
7.1.70.0070.00616.50
7.1.60.0080.01017.72
7.1.50.0140.00525.26
7.1.40.0100.00315.54
7.1.30.0090.00315.67
7.1.20.0030.01015.53
7.1.10.0000.01715.63
7.1.00.0030.04419.06
7.0.330.0110.00415.32
7.0.320.0100.00615.52
7.0.310.0100.00715.57
7.0.300.0040.01215.49
7.0.290.0050.00815.11
7.0.280.0040.01115.35
7.0.270.0100.00315.34
7.0.260.0070.00715.23
7.0.250.0070.00415.20
7.0.240.0060.00915.57
7.0.230.0070.00715.31
7.0.220.0140.00015.17
7.0.210.0110.00415.18
7.0.200.0060.00316.05
7.0.190.0060.00315.22
7.0.180.0060.00915.44
7.0.170.0080.00015.21
7.0.160.0070.00715.34
7.0.150.0080.00415.37
7.0.140.0030.04218.71
7.0.130.0040.00515.36
7.0.120.0090.00615.19
7.0.110.0140.00015.37
7.0.100.0000.01515.22
7.0.90.0060.00615.34
7.0.80.0000.01215.66
7.0.70.0090.00315.58
7.0.60.0090.04217.73
7.0.50.0030.03016.72
7.0.40.0100.04316.91
7.0.30.0150.03016.88
7.0.20.0150.03816.79
7.0.10.0210.03716.69
7.0.00.0080.02116.69
5.6.380.0090.00614.65
5.6.370.0070.00714.13
5.6.360.0060.00914.31
5.6.350.0100.00614.71
5.6.340.0150.00014.55
5.6.330.0030.00614.16
5.6.320.0030.01014.24
5.6.310.0060.00913.96
5.6.300.0040.00714.59
5.6.290.0060.01014.15
5.6.280.0050.04217.84
5.6.270.0090.00014.36
5.6.260.0000.01214.21
5.6.250.0100.00714.55
5.6.240.0080.00314.62
5.6.230.0060.00614.34
5.6.220.0000.00814.67
5.6.210.0050.02517.61
5.6.200.0020.04416.34
5.6.190.0080.04817.62
5.6.180.0100.04417.38
5.6.170.0150.03917.47
5.6.160.0080.03217.64
5.6.150.0070.04316.23
5.6.140.0010.03616.26
5.6.130.0050.03016.31
5.6.120.0120.04017.61
5.6.110.0070.05017.58
5.6.100.0030.04117.76
5.6.90.0120.03717.65
5.6.80.0020.05217.51
5.6.70.2320.02317.45
5.6.60.0050.00314.14
5.6.50.0000.00814.39
5.6.40.0060.00614.29
5.6.30.0040.01114.54
5.6.20.0060.00614.62
5.6.10.0080.00814.29
5.6.00.0040.00414.53
5.5.380.0030.00711.11
5.5.370.0060.00011.18
5.5.360.0030.00311.04
5.5.350.0050.03515.86
5.5.340.0020.02714.51
5.5.330.0030.02415.71
5.5.320.0180.03315.59
5.5.310.0140.04215.77
5.5.300.0060.04114.62
5.5.290.0030.03114.62
5.5.280.0080.04116.10
5.5.270.0030.03016.20
5.5.260.0050.04616.08
5.5.250.0100.03315.99
5.5.240.0070.03715.73
5.5.230.0050.00311.00
5.5.220.0000.01111.23
5.5.210.0110.00010.99
5.5.200.0030.00711.18
5.5.190.0030.01011.34
5.5.180.0040.00710.99
5.5.170.0000.01011.27
5.5.160.0000.00810.99
5.5.150.0030.00711.29
5.5.140.0000.01111.37
5.5.130.0000.00611.14
5.5.120.0060.00611.30
5.5.110.0110.00011.03
5.5.100.0060.00611.34
5.5.90.0040.00711.28
5.5.80.0030.00311.32
5.5.70.0000.00711.18
5.5.60.0070.00711.00
5.5.50.0000.01211.29
5.5.40.0110.00010.78
5.5.30.0070.00611.00
5.5.20.0110.00010.94
5.5.10.0040.00411.06
5.5.00.0040.00710.83
5.4.450.0100.03215.17
5.4.440.0150.04415.32
5.4.430.0090.03215.49
5.4.420.0110.03115.22
5.4.410.0100.03115.30
5.4.400.0080.03515.16
5.4.390.0150.04015.19
5.4.380.0210.02715.06
5.4.370.0240.02514.81
5.4.360.0200.02515.01
5.4.350.0150.03314.91
5.4.340.0150.03214.85
5.4.330.0060.00610.91
5.4.320.0070.02511.73
5.4.310.0040.02711.58
5.4.300.0060.02411.86
5.4.290.0030.03111.77
5.4.280.0060.02711.67
5.4.270.0080.02811.56
5.4.260.0100.02511.85
5.4.250.0070.02711.75
5.4.240.0060.02811.72
5.4.230.0080.02311.66
5.4.220.0040.02411.70
5.4.210.0080.02011.75
5.4.200.0040.02611.67
5.4.190.0070.03711.71
5.4.180.0050.03011.89
5.4.170.0040.02911.72
5.4.160.0060.02811.72
5.4.150.0070.02411.69
5.4.140.0090.02611.48
5.4.130.0080.02111.52
5.4.120.0060.02511.57
5.4.110.0110.02411.32
5.4.100.0080.02611.44
5.4.90.0060.02211.50
5.4.80.0060.02811.54
5.4.70.0090.02711.63
5.4.60.0070.02311.54
5.4.50.0050.02511.66
5.4.40.0050.02311.59
5.4.30.0070.02011.38
5.4.20.0060.02311.43
5.4.10.0080.02611.68
5.4.00.0070.02411.28
5.3.290.0060.02611.80
5.3.280.0050.02511.66
5.3.270.0050.03211.72
5.3.260.0070.02411.76
5.3.250.0040.03011.77
5.3.240.0060.02811.66
5.3.230.0060.02711.64
5.3.220.0090.02711.51
5.3.210.0070.02811.65
5.3.200.0070.02411.65
5.3.190.0050.02911.57
5.3.180.0070.02711.59
5.3.170.0080.02811.75
5.3.160.0080.02911.75
5.3.150.0070.02711.63
5.3.140.0080.02811.71
5.3.130.0090.02611.70
5.3.120.0060.02711.67
5.3.110.0050.03111.71
5.3.100.0050.03211.43
5.3.90.0090.02611.37
5.3.80.0070.02511.34
5.3.70.0030.03111.28
5.3.60.0070.02711.36
5.3.50.0070.02811.36
5.3.40.0040.03111.38
5.3.30.0060.02811.22
5.3.20.0050.02711.19
5.3.10.0090.02611.07
5.3.00.0040.03011.09
5.2.170.0060.0249.45
5.2.160.0060.0209.41
5.2.150.0030.0279.44
5.2.140.0050.0229.42
5.2.130.0040.0249.41
5.2.120.0050.0229.38
5.2.110.0060.0209.38
5.2.100.0060.0339.36
5.2.90.0060.0229.37
5.2.80.0040.0239.35
5.2.70.0050.0249.33
5.2.60.0080.0239.27
5.2.50.0070.0409.32
5.2.40.0040.0239.29
5.2.30.0070.0429.28
5.2.20.0050.0339.26
5.2.10.0060.0299.06
5.2.00.0050.0328.88
5.1.60.0050.0148.39
5.1.50.0030.0308.39
5.1.40.0070.0198.38
5.1.30.0040.0258.56
5.1.20.0050.0248.57
5.1.10.0040.0208.44
5.1.00.0080.0198.43
5.0.50.0060.0137.67
5.0.40.0040.0137.60
5.0.30.0020.0217.51
5.0.20.0060.0127.49
5.0.10.0040.0157.48
5.0.00.0060.0197.48
4.4.90.0080.0136.73
4.4.80.0020.0136.72
4.4.70.0030.0136.72
4.4.60.0050.0096.72
4.4.50.0010.0126.73
4.4.40.0050.0316.70
4.4.30.0030.0126.72
4.4.20.0040.0126.77
4.4.10.0030.0136.77
4.4.00.0040.0176.72
4.3.110.0020.0146.68
4.3.100.0030.0136.68
4.3.90.0040.0126.66
4.3.80.0090.0226.64
4.3.70.0040.0156.66
4.3.60.0040.0146.66
4.3.50.0020.0186.66
4.3.40.0040.0236.61
4.3.30.0040.0135.99
4.3.20.0040.0195.98
4.3.10.0040.0115.96
4.3.00.0250.0149.61

preferences:
50.8 ms | 400 KiB | 5 Q