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']); // 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.0150.00316.50
8.3.50.0150.00722.12
8.3.40.0140.00718.83
8.3.30.0070.00719.21
8.3.20.0040.00420.16
8.3.10.0040.00423.55
8.3.00.0000.00819.38
8.2.180.0120.00618.54
8.2.170.0110.00422.96
8.2.160.0030.01020.53
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00422.32
8.2.110.0000.00920.47
8.2.100.0090.00317.87
8.2.90.0040.00419.26
8.2.80.0000.00817.97
8.2.70.0030.00517.63
8.2.60.0000.00817.93
8.2.50.0000.00818.22
8.2.40.0040.00420.46
8.2.30.0040.00419.43
8.2.20.0040.00417.73
8.2.10.0050.00318.24
8.2.00.0060.00317.73
8.1.280.0100.01025.92
8.1.270.0040.00423.84
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0050.00523.97
8.1.230.0040.00817.83
8.1.220.0040.00417.79
8.1.210.0060.00318.77
8.1.200.0050.00517.48
8.1.190.0090.00017.35
8.1.180.0080.00020.20
8.1.170.0040.00418.70
8.1.160.0040.00418.94
8.1.150.0070.00020.18
8.1.140.0000.00817.35
8.1.130.0030.00317.80
8.1.120.0000.00817.51
8.1.110.0000.00917.48
8.1.100.0040.00417.46
8.1.90.0040.00417.50
8.1.80.0000.00717.52
8.1.70.0000.00717.45
8.1.60.0000.00917.69
8.1.50.0050.00517.51
8.1.40.0050.00317.56
8.1.30.0080.00017.55
8.1.20.0090.00017.68
8.1.10.0000.00817.54
8.1.00.0030.00617.60
8.0.300.0000.00918.77
8.0.290.0050.00316.75
8.0.280.0080.00018.48
8.0.270.0000.00717.27
8.0.260.0020.00517.30
8.0.250.0070.00016.99
8.0.240.0000.00917.06
8.0.230.0040.00417.07
8.0.220.0000.00717.01
8.0.210.0000.00716.91
8.0.200.0000.00617.00
8.0.190.0000.00817.00
8.0.180.0000.00816.99
8.0.170.0000.00816.95
8.0.160.0000.00716.95
8.0.150.0040.00416.91
8.0.140.0070.00016.99
8.0.130.0060.00013.49
8.0.120.0040.00416.84
8.0.110.0040.00416.91
8.0.100.0080.00016.78
8.0.90.0030.00516.80
8.0.80.0090.00617.05
8.0.70.0000.00716.83
8.0.60.0050.00217.04
8.0.50.0000.00716.83
8.0.30.0140.00717.24
8.0.20.0130.00617.40
8.0.10.0000.00716.89
8.0.00.0110.01016.91
7.4.330.0040.00415.00
7.4.320.0000.00716.64
7.4.300.0060.00016.63
7.4.290.0040.00416.48
7.4.280.0030.00316.68
7.4.270.0040.00416.64
7.4.260.0040.00416.63
7.4.250.0020.00516.55
7.4.240.0030.00416.68
7.4.230.0080.00016.58
7.4.220.0060.01316.62
7.4.210.0080.00716.71
7.4.200.0070.00016.58
7.4.190.0040.00416.81
7.4.160.0110.00716.73
7.4.150.0090.00917.40
7.4.140.0090.00917.86
7.4.130.0080.00816.58
7.4.120.0100.00616.50
7.4.110.0140.01016.50
7.4.100.0110.00816.61
7.4.90.0070.01116.45
7.4.80.0160.00319.39
7.4.70.0070.01516.66
7.4.60.0120.00616.37
7.4.50.0030.00316.46
7.4.40.0060.00922.77
7.4.30.0030.01616.51
7.4.10.0040.01415.13
7.4.00.0050.01215.10
7.3.330.0060.00013.25
7.3.320.0030.00313.46
7.3.310.0000.00716.32
7.3.300.0060.00316.43
7.3.290.0080.01416.44
7.3.280.0110.00816.45
7.3.270.0090.00917.40
7.3.260.0070.01016.57
7.3.250.0130.00416.62
7.3.240.0060.01316.76
7.3.230.0070.01016.64
7.3.210.0090.00916.61
7.3.200.0130.01019.39
7.3.190.0190.00316.39
7.3.180.0130.00316.61
7.3.170.0080.00816.62
7.3.160.0060.01216.67
7.3.130.0100.00714.72
7.3.120.0080.00814.88
7.3.110.0020.01615.10
7.3.100.0090.00714.84
7.3.90.0100.00614.96
7.3.80.0060.01015.00
7.3.70.0070.00514.85
7.3.60.0060.00614.84
7.3.50.0040.01114.88
7.3.40.0080.00314.82
7.3.30.0050.00914.91
7.3.20.0060.00616.61
7.3.10.0040.00916.62
7.3.00.0080.00916.59
7.2.330.0090.00916.66
7.2.320.0120.00816.85
7.2.310.0070.01116.64
7.2.300.0100.00716.77
7.2.290.0120.00916.77
7.2.260.0090.00915.32
7.2.250.0030.01315.08
7.2.240.0080.00715.09
7.2.230.0090.00915.19
7.2.220.0110.00815.26
7.2.210.0050.01215.29
7.2.200.0020.01315.13
7.2.190.0040.00915.16
7.2.180.0030.01214.96
7.2.170.0070.00715.01
7.2.160.0100.00715.18
7.2.150.0030.00617.04
7.2.140.0030.00716.95
7.2.130.0060.00916.64
7.2.120.0140.00016.95
7.2.110.0060.00616.88
7.2.100.0090.00317.07
7.2.90.0070.01116.69
7.2.80.0000.01116.87
7.2.70.0070.00716.95
7.2.60.0060.00816.98
7.2.50.0090.00616.88
7.2.40.0050.00516.70
7.2.30.0060.00616.63
7.2.20.0000.01416.79
7.2.10.0030.01216.97
7.2.00.0060.00918.21
7.1.330.0030.00815.75
7.1.320.0090.00515.78
7.1.310.0060.00815.91
7.1.300.0030.00715.71
7.1.290.0070.00815.95
7.1.280.0050.00815.88
7.1.270.0080.00215.82
7.1.260.0040.00615.69
7.1.250.0100.00715.78
7.1.240.0090.00615.51
7.1.230.0030.00915.58
7.1.220.0070.01015.86
7.1.210.0030.01415.86
7.1.200.0030.01015.67
7.1.190.0120.00015.85
7.1.180.0120.00315.71
7.1.170.0090.00415.83
7.1.160.0060.01115.93
7.1.150.0030.01015.79
7.1.140.0030.01015.61
7.1.130.0120.00315.79
7.1.120.0070.01015.85
7.1.110.0030.01415.59
7.1.100.0080.00617.08
7.1.90.0090.00915.66
7.1.80.0070.01015.80
7.1.70.0080.00816.51
7.1.60.0100.01017.57
7.1.50.0140.00916.22
7.1.40.0070.00715.59
7.1.30.0100.01015.73
7.1.20.0040.01515.79
7.1.10.0000.01315.72
7.1.00.0030.04419.13
7.0.330.0040.01115.15
7.0.320.0040.01115.17
7.0.310.0080.00815.28
7.0.300.0040.00815.36
7.0.290.0030.00715.35
7.0.280.0060.00615.24
7.0.270.0070.01015.14
7.0.260.0090.00615.64
7.0.250.0060.01115.24
7.0.240.0080.00415.22
7.0.230.0110.00415.42
7.0.220.0000.01415.39
7.0.210.0110.00315.42
7.0.200.0040.00616.13
7.0.190.0060.00615.54
7.0.180.0060.00615.58
7.0.170.0080.00415.41
7.0.160.0100.00715.21
7.0.150.0090.00915.42
7.0.140.0100.03818.67
7.0.130.0040.01115.33
7.0.120.0040.01515.41
7.0.110.0150.02817.79
7.0.100.0100.02217.74
7.0.90.0270.02517.63
7.0.80.0050.03017.83
7.0.70.0090.02317.72
7.0.60.0080.01817.62
7.0.50.0050.02517.80
7.0.40.0030.02316.54
7.0.30.0040.02616.72
7.0.20.0070.03016.61
7.0.10.0100.03716.53
7.0.00.0080.03016.60
5.6.400.0000.01414.74
5.6.390.0000.00914.47
5.6.380.0090.00614.58
5.6.370.0040.01414.63
5.6.360.0080.00814.33
5.6.350.0030.01314.68
5.6.340.0030.00914.04
5.6.330.0030.00914.79
5.6.320.0000.01014.63
5.6.310.0120.00314.45
5.6.300.0000.01314.64
5.6.290.0000.01514.64
5.6.280.0050.03917.81
5.6.270.0040.01514.63
5.6.260.0050.02517.57
5.6.250.0060.02217.42
5.6.240.0020.02817.49
5.6.230.0050.02317.52
5.6.220.0020.03117.53
5.6.210.0070.02317.43
5.6.200.0060.02517.42
5.6.190.0060.01917.61
5.6.180.0050.03517.60
5.6.170.0070.02517.54
5.6.160.0100.04117.58
5.6.150.0050.02317.46
5.6.140.0050.04317.62
5.6.130.0030.04517.58
5.6.120.0050.02017.48
5.6.110.0040.03617.44
5.6.100.0090.03017.41
5.6.90.0080.03817.64
5.6.80.0050.02517.20
5.6.70.0030.03817.21
5.6.60.0030.02217.13
5.6.50.0140.02717.12
5.6.40.0080.02317.21
5.6.30.0030.01917.11
5.6.20.0040.02917.11
5.6.10.0060.04617.18
5.6.00.0050.01717.14
5.5.380.0040.02615.90
5.5.370.0010.02415.94
5.5.360.0070.02015.82
5.5.350.0020.02115.99
5.5.340.0030.02716.19
5.5.330.0030.02516.40
5.5.320.0070.02716.58
5.5.310.0040.03116.14
5.5.300.0070.03216.17
5.5.290.0030.02216.31
5.5.280.0050.03516.31
5.5.270.0050.01915.98
5.5.260.0060.02316.41
5.5.250.0070.04216.02
5.5.240.0030.02415.86
5.5.230.0030.03116.01
5.5.220.0060.02015.80
5.5.210.0050.02015.86
5.5.200.0030.02215.86
5.5.190.0030.02416.04
5.5.180.0040.03915.83
5.5.170.0080.00414.32
5.5.160.0040.04215.72
5.5.150.0120.03515.94
5.5.140.0100.03316.05
5.5.130.0020.02815.75
5.5.120.0060.04015.75
5.5.110.0100.02315.74
5.5.100.0050.02015.87
5.5.90.0050.03815.58
5.5.80.0020.03215.89
5.5.70.0040.02715.85
5.5.60.0120.01815.76
5.5.50.0060.04015.81
5.5.40.0080.02015.82
5.5.30.0020.02715.73
5.5.20.0060.04015.78
5.5.10.0080.03815.67
5.5.00.0070.03815.81
5.4.450.0040.03415.41
5.4.440.0050.02715.33
5.4.430.0070.04215.38
5.4.420.0080.03315.17
5.4.410.0020.04315.27
5.4.400.0070.04015.03
5.4.390.0050.04114.95
5.4.380.0050.03315.12
5.4.370.0050.03715.12
5.4.360.0080.02515.13
5.4.350.0060.03615.04
5.4.340.0040.03414.90
5.4.330.0000.01011.07
5.4.320.0050.04514.99
5.4.310.0080.03615.13
5.4.300.0070.04315.06
5.4.290.0060.03115.19
5.4.280.0030.01814.99
5.4.270.0100.03015.18
5.4.260.0050.02015.20
5.4.250.0050.03815.14
5.4.240.0070.01815.09
5.4.230.0060.03215.13
5.4.220.0030.04514.84
5.4.210.0030.03015.07
5.4.200.0050.04815.06
5.4.190.0070.03715.13
5.4.180.0030.04315.32
5.4.170.0050.02715.12
5.4.160.0050.03315.05
5.4.150.0030.04415.16
5.4.140.0070.02513.83
5.4.130.0050.04013.63
5.4.120.0050.03913.70
5.4.110.0030.02513.78
5.4.100.0050.04113.72
5.4.90.0020.04513.87
5.4.80.0110.02913.81
5.4.70.0050.03813.83
5.4.60.0040.02013.80
5.4.50.0080.01513.51
5.4.40.0060.01813.75
5.4.30.0070.03213.97
5.4.20.0030.02013.83
5.4.10.0080.02313.66
5.4.00.0030.02013.52
5.3.290.0060.04412.73
5.3.280.0060.03812.48
5.3.270.0100.03612.73
5.3.260.0060.02212.64
5.3.250.0100.02612.66
5.3.240.0100.03112.54
5.3.230.0110.02012.58
5.3.220.0090.01912.54
5.3.210.0100.03812.52
5.3.200.0070.04012.50
5.3.190.0070.04012.70
5.3.180.0120.02012.67
5.3.170.0130.01512.68
5.3.160.0070.03412.64
5.3.150.0090.02412.61
5.3.140.0090.03712.64
5.3.130.0130.03712.61
5.3.120.0070.04012.63
5.3.110.0050.02412.46
5.3.100.0050.02112.30
5.3.90.0050.02112.45
5.3.80.0140.03012.37
5.3.70.0080.01812.39
5.3.60.0120.03712.34
5.3.50.0090.02912.32
5.3.40.0050.04012.25
5.3.30.0130.03512.35
5.3.20.0090.03412.21
5.3.10.0070.03312.11
5.3.00.0100.03812.08
5.2.170.0070.05711.84
5.2.160.0030.06711.84
5.2.150.0070.05011.84
5.2.140.0100.05011.84
5.2.130.0000.05711.84
5.2.120.0030.06311.84
5.2.110.0070.02311.84
5.2.100.0070.03311.84
5.2.90.0070.02711.84
5.2.80.0100.04311.84
5.2.70.0000.03311.84
5.2.60.0100.04711.84
5.2.50.0100.03011.84
5.2.40.0030.02711.84
5.2.30.0000.03711.84
5.2.20.0030.04711.84
5.2.10.0070.04011.84
5.2.00.0070.02311.84
5.1.60.0030.03011.84
5.1.50.0000.02711.84
5.1.40.0070.02011.84
5.1.30.0100.05011.84
5.1.20.0070.02011.84
5.1.10.0000.02711.84
5.1.00.0000.05011.84
5.0.50.0100.01711.84
5.0.40.0030.02011.84
5.0.30.0000.03311.84
5.0.20.0070.01311.84
5.0.10.0030.02011.84
5.0.00.0030.04311.84
4.4.90.0030.01311.84
4.4.80.0030.03311.84
4.4.70.0070.00711.84
4.4.60.0030.01011.84
4.4.50.0030.02711.84
4.4.40.0000.02711.84
4.4.30.0000.01711.84
4.4.20.0030.01311.84
4.4.10.0000.01711.84
4.4.00.0000.04011.84
4.3.110.0030.01311.84
4.3.100.0000.03711.84
4.3.90.0000.01711.84
4.3.80.0030.02311.84
4.3.70.0000.03311.84
4.3.60.0070.02311.84
4.3.50.0030.02711.84
4.3.40.0000.02011.84
4.3.30.0000.02311.84
4.3.20.0000.02311.84
4.3.10.0000.03011.84
4.3.00.0000.02311.84

preferences:
47.89 ms | 401 KiB | 5 Q