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']); $func = function(){ $test->secret = "Yummy"; }; return $func->bindTo($test->test, 'Test'); // 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.0110.01116.75
8.3.50.0170.00521.95
8.3.40.0180.00018.68
8.3.30.0000.01419.07
8.3.20.0040.00420.29
8.3.10.0080.00023.66
8.3.00.0090.00019.47
8.2.180.0030.02018.48
8.2.170.0060.01522.96
8.2.160.0030.01520.53
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00422.30
8.2.110.0030.00622.25
8.2.100.0090.00317.97
8.2.90.0080.00019.21
8.2.80.0050.00318.03
8.2.70.0030.00617.63
8.2.60.0000.00818.03
8.2.50.0000.00818.07
8.2.40.0000.00919.95
8.2.30.0000.00718.21
8.2.20.0030.00517.72
8.2.10.0040.00418.11
8.2.00.0030.00717.85
8.1.280.0030.01325.92
8.1.270.0090.00023.75
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.74
8.1.230.0080.00319.16
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0060.00317.35
8.1.190.0000.00817.64
8.1.180.0070.00319.14
8.1.170.0040.00418.65
8.1.160.0000.00722.10
8.1.150.0090.00018.73
8.1.140.0040.00417.50
8.1.130.0030.00317.88
8.1.120.0040.00417.55
8.1.110.0000.00817.41
8.1.100.0000.00817.43
8.1.90.0000.00817.45
8.1.80.0000.00717.52
8.1.70.0030.00317.48
8.1.60.0020.00517.54
8.1.50.0050.00317.48
8.1.40.0050.00317.55
8.1.30.0000.00817.66
8.1.20.0000.00917.60
8.1.10.0000.00817.59
8.1.00.0020.00517.61
8.0.300.0040.00418.77
8.0.290.0040.00417.30
8.0.280.0050.00218.52
8.0.270.0030.00317.22
8.0.260.0030.00317.25
8.0.250.0000.00717.06
8.0.240.0080.00016.97
8.0.230.0030.00317.01
8.0.220.0030.00317.00
8.0.210.0050.00216.89
8.0.200.0030.00317.03
8.0.190.0050.00317.03
8.0.180.0080.00017.06
8.0.170.0040.00416.95
8.0.160.0000.00716.99
8.0.150.0040.00416.92
8.0.140.0000.00716.93
8.0.130.0000.00613.42
8.0.120.0000.00816.98
8.0.110.0050.00216.92
8.0.100.0000.00716.96
8.0.90.0040.00416.89
8.0.80.0100.00617.03
8.0.70.0030.00616.90
8.0.60.0040.00417.03
8.0.50.0000.00716.80
8.0.30.0080.01117.22
8.0.20.0080.01317.40
8.0.10.0070.00016.99
8.0.00.0100.00816.86
7.4.330.0030.00315.09
7.4.320.0000.00716.66
7.4.300.0040.00416.65
7.4.290.0000.00816.70
7.4.280.0000.00816.55
7.4.270.0000.00716.63
7.4.260.0070.00016.40
7.4.250.0040.00416.53
7.4.240.0040.00416.58
7.4.230.0000.00716.75
7.4.220.0100.00716.53
7.4.210.0080.00916.64
7.4.200.0040.00416.69
7.4.190.0030.00316.70
7.4.160.0090.00616.39
7.4.150.0180.00017.40
7.4.140.0060.01117.86
7.4.130.0060.01116.59
7.4.120.0060.01116.63
7.4.110.0190.00316.56
7.4.100.0090.00916.41
7.4.90.0000.01616.56
7.4.80.0060.01319.39
7.4.70.0110.00816.52
7.4.60.0150.01016.54
7.4.50.0030.00316.28
7.4.40.0060.00922.77
7.4.30.0060.01016.60
7.4.10.0070.01114.68
7.4.00.0060.01315.11
7.3.330.0030.00313.40
7.3.320.0030.00313.46
7.3.310.0030.00516.57
7.3.300.0060.00316.43
7.3.290.0110.00616.55
7.3.280.0100.00916.42
7.3.270.0100.00717.40
7.3.260.0140.00616.78
7.3.250.0140.00316.41
7.3.240.0070.01016.45
7.3.230.0130.00316.51
7.3.210.0120.00416.41
7.3.200.0170.01619.39
7.3.190.0110.00716.67
7.3.180.0040.01216.50
7.3.170.0080.00716.55
7.3.160.0080.00816.45
7.3.130.0060.01314.70
7.3.120.0050.01214.95
7.3.110.0040.01114.90
7.3.100.0060.00915.08
7.3.90.0080.00514.75
7.3.80.0060.00615.03
7.3.70.0080.00514.86
7.3.60.0030.01115.06
7.3.50.0070.00614.85
7.3.40.0100.00514.89
7.3.30.0040.01214.70
7.3.20.0050.00916.77
7.3.10.0070.00616.63
7.3.00.0060.00816.66
7.2.330.0090.01216.76
7.2.320.0110.00716.51
7.2.310.0000.01616.51
7.2.300.0080.00816.69
7.2.290.0060.01216.61
7.2.260.0070.01015.34
7.2.250.0100.00715.26
7.2.240.0050.00915.09
7.2.230.0040.01015.19
7.2.220.0070.00615.21
7.2.210.0060.01114.92
7.2.200.0060.00915.09
7.2.190.0030.01015.08
7.2.180.0080.00615.00
7.2.170.0050.00815.16
7.2.160.0050.01215.18
7.2.150.0050.00916.82
7.2.140.0060.00916.96
7.2.130.0050.00816.97
7.2.120.0020.01316.98
7.2.110.0020.00916.96
7.2.100.0040.00916.86
7.2.90.0070.00717.00
7.2.80.0070.00716.90
7.2.70.0070.00617.04
7.2.60.0060.00816.95
7.2.50.0070.00716.83
7.2.40.0090.00617.00
7.2.30.0050.00717.07
7.2.20.0050.00916.81
7.2.10.0080.00716.83
7.2.00.0030.01217.46
7.1.330.0060.00915.75
7.1.320.0060.00715.82
7.1.310.0040.00815.80
7.1.300.0100.00515.82
7.1.290.0050.01115.88
7.1.280.0040.01015.71
7.1.270.0060.00615.72
7.1.260.0050.00915.68
7.1.250.0050.00915.83
7.1.240.0030.01315.87
7.1.230.0030.01015.98
7.1.220.0070.00715.95
7.1.210.0040.00815.94
7.1.200.0050.00915.56
7.1.190.0030.01015.78
7.1.180.0060.00615.82
7.1.170.0000.01315.74
7.1.160.0070.00715.88
7.1.150.0030.00615.83
7.1.140.0090.00615.58
7.1.130.0110.00315.59
7.1.120.0000.01415.92
7.1.110.0030.01015.49
7.1.100.0050.00817.10
7.1.90.0070.00715.82
7.1.80.0070.01115.88
7.1.70.0080.00616.46
7.1.60.0070.01317.62
7.1.50.0150.00625.42
7.1.40.0130.00015.72
7.1.30.0060.00915.68
7.1.20.0040.00415.80
7.1.10.0030.00915.88
7.1.00.0030.04319.12
7.0.330.0070.00315.42
7.0.320.0000.01415.18
7.0.310.0000.01015.61
7.0.300.0030.01315.19
7.0.290.0030.01215.19
7.0.280.0000.01015.32
7.0.270.0060.01015.60
7.0.260.0030.00715.46
7.0.250.0060.00615.20
7.0.240.0030.01415.39
7.0.230.0100.00615.33
7.0.220.0030.01415.46
7.0.210.0140.00715.45
7.0.200.0070.00615.18
7.0.190.0000.00815.41
7.0.180.0070.00715.26
7.0.170.0120.00315.52
7.0.160.0000.00815.45
7.0.150.0080.00515.49
7.0.140.0030.04218.67
7.0.130.0070.00415.41
7.0.120.0100.00315.30
7.0.110.0080.00615.51
7.0.100.0070.00715.39
7.0.90.0070.00415.64
7.0.80.0100.00315.46
7.0.70.0070.00715.29
7.0.60.0080.02417.66
7.0.50.0080.02116.73
7.0.40.0050.03216.92
7.0.30.0250.03816.83
7.0.20.0170.03016.89
7.0.10.0150.03816.91
7.0.00.0050.04416.95
5.6.400.0030.01214.61
5.6.390.0090.00914.52
5.6.380.0070.01014.41
5.6.370.0070.00714.50
5.6.360.0100.00314.70
5.6.350.0060.00314.53
5.6.340.0040.00814.17
5.6.330.0060.01314.72
5.6.320.0070.00714.28
5.6.310.0080.00014.08
5.6.300.0000.01414.34
5.6.290.0090.00614.42
5.6.280.0040.04017.78
5.6.270.0090.00614.63
5.6.260.0100.00014.39
5.6.250.0030.00614.41
5.6.240.0030.00614.56
5.6.230.0120.00314.26
5.6.220.0040.00714.73
5.6.210.0070.04417.65
5.6.200.0090.04116.38
5.6.190.0020.05217.54
5.6.180.0150.02417.45
5.6.170.0100.02817.30
5.6.160.0120.04017.38
5.6.150.0040.02216.38
5.6.140.0070.04116.23
5.6.130.0080.04216.16
5.6.120.0090.03417.69
5.6.110.0080.03617.57
5.6.100.0090.04417.62
5.6.90.0070.04517.75
5.6.80.0130.03517.45
5.6.70.0030.01414.51
5.6.60.0100.00314.50
5.6.50.0060.00614.52
5.6.40.0040.00714.66
5.6.30.0060.00614.43
5.6.20.0000.00914.67
5.6.10.0060.01014.27
5.6.00.0000.01114.38
5.5.380.0070.00314.48
5.5.370.0070.00714.16
5.5.360.0070.00714.36
5.5.350.0080.02917.36
5.5.340.0050.02616.24
5.5.330.0080.02317.43
5.5.320.0230.03517.32
5.5.310.0160.01817.48
5.5.300.0050.02316.15
5.5.290.0080.02216.19
5.5.280.0070.03117.69
5.5.270.0050.02517.61
5.5.260.0050.02817.70
5.5.250.0100.04017.50
5.5.240.0230.04017.29
5.5.230.0040.00814.26
5.5.220.0040.00814.29
5.5.210.0040.00814.33
5.5.200.0030.01314.39
5.5.190.0060.00614.43
5.5.180.0040.00713.99
5.5.170.0090.00014.27
5.5.160.0000.01514.16
5.5.150.0110.00014.24
5.5.140.0030.00914.41
5.5.130.0070.00714.21
5.5.120.0000.00814.20
5.5.110.0000.00814.47
5.5.100.0060.00614.47
5.5.90.0070.01014.61
5.5.80.0070.00414.40
5.5.70.0080.00614.09
5.5.60.0130.00314.40
5.5.50.0100.00314.49
5.5.40.0000.01514.21
5.5.30.0000.01114.25
5.5.20.0060.00914.23
5.5.10.0050.00514.44
5.5.00.0040.00814.10
5.4.450.0080.01816.06
5.4.440.0050.02516.03
5.4.430.0060.02016.05
5.4.420.0020.02716.03
5.4.410.0050.02815.99
5.4.400.0030.04315.90
5.4.390.0070.02015.85
5.4.380.0020.03515.86
5.4.370.0030.03515.94
5.4.360.0050.03115.86
5.4.350.0030.02515.82
5.4.340.0050.04015.86
5.4.330.0040.00412.64
5.4.320.0040.02215.89
5.4.310.0020.03015.93
5.4.300.0030.02315.89
5.4.290.0070.03315.87
5.4.280.0040.03115.74
5.4.270.0050.04015.88
5.4.260.0080.03515.85
5.4.250.0050.03515.80
5.4.240.0060.04015.80
5.4.230.0070.04015.93
5.4.220.0020.04215.93
5.4.210.0050.02315.88
5.4.200.0070.03915.88
5.4.190.0050.04115.88
5.4.180.0090.03615.91
5.4.170.0020.04315.97
5.4.160.0050.02515.92
5.4.150.0070.04015.91
5.4.140.0100.03514.60
5.4.130.0030.04114.49
5.4.120.0040.03414.51
5.4.110.0060.02514.61
5.4.100.0010.02914.48
5.4.90.0070.02314.63
5.4.80.0030.02514.48
5.4.70.0000.04414.56
5.4.60.0050.03514.58
5.4.50.0080.03514.52
5.4.40.0030.04014.56
5.4.30.0080.03814.40
5.4.20.0040.04014.54
5.4.10.0020.02714.40
5.4.00.0000.02914.22
5.3.290.0080.02413.62
5.3.280.0070.02813.63
5.3.270.0070.01813.74
5.3.260.0030.04213.65
5.3.250.0000.03913.67
5.3.240.0050.03913.58
5.3.230.0030.04213.58
5.3.220.0040.03813.69
5.3.210.0050.03713.61
5.3.200.0050.02213.57
5.3.190.0060.04013.67
5.3.180.0000.04713.62
5.3.170.0010.02913.62
5.3.160.0050.03713.57
5.3.150.0150.02513.62
5.3.140.0030.03013.61
5.3.130.0050.03313.61
5.3.120.0030.04313.64
5.3.110.0030.02813.60
5.3.100.0050.02713.40
5.3.90.0050.03313.36
5.3.80.0030.02613.45
5.3.70.0030.03913.29
5.3.60.0030.04013.29
5.3.50.0020.03213.29
5.3.40.0060.03813.36
5.3.30.0070.03513.29
5.3.20.0020.02313.21
5.3.10.0050.03013.12
5.3.00.0060.02513.15
5.2.170.0030.03011.94
5.2.160.0070.04311.94
5.2.150.0000.04711.94
5.2.140.0030.06011.94
5.2.130.0030.03011.94
5.2.120.0100.05311.94
5.2.110.0070.06011.94
5.2.100.0000.03711.94
5.2.90.0030.06011.94
5.2.80.0000.03011.94
5.2.70.0030.06011.94
5.2.60.0070.05311.94
5.2.50.0030.05311.94
5.2.40.0030.06311.94
5.2.30.0030.06011.94
5.2.20.0000.05011.94
5.2.10.0030.04011.94
5.2.00.0070.06011.94
5.1.60.0070.04711.94
5.1.50.0030.05311.94
5.1.40.0030.03011.94
5.1.30.0070.05011.94
5.1.20.0100.05011.94
5.1.10.0030.05311.94
5.1.00.0000.03711.94
5.0.50.0000.05011.94
5.0.40.0030.03711.94
5.0.30.0030.06311.94
5.0.20.0030.04311.94
5.0.10.0000.03311.94
5.0.00.0030.06311.94
4.4.90.0070.03011.94
4.4.80.0070.02711.94
4.4.70.0030.03311.94
4.4.60.0000.03011.94
4.4.50.0030.02311.94
4.4.40.0030.04711.94
4.4.30.0000.03011.94
4.4.20.0000.01711.94
4.4.10.0030.03711.94
4.4.00.0030.03311.94
4.3.110.0030.03711.94
4.3.100.0030.02011.94
4.3.90.0000.03711.94
4.3.80.0000.04711.94
4.3.70.0000.03311.94
4.3.60.0000.03311.94
4.3.50.0030.02311.94
4.3.40.0000.04311.94
4.3.30.0000.03011.94
4.3.20.0000.04011.94
4.3.10.0000.03711.94
4.3.00.0000.03711.94

preferences:
52.55 ms | 401 KiB | 5 Q