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 var_dump('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.0060.00916.63
8.3.50.0090.01022.06
8.3.40.0100.01018.71
8.3.30.0170.00319.22
8.3.20.0000.00720.40
8.3.10.0030.00523.48
8.3.00.0040.00419.38
8.2.180.0110.01116.63
8.2.170.0060.00922.96
8.2.160.0090.00620.28
8.2.150.0000.00724.18
8.2.140.0080.00024.66
8.2.130.0070.00726.16
8.2.120.0030.00522.11
8.2.110.0080.00022.29
8.2.100.0080.00317.84
8.2.90.0000.00819.25
8.2.80.0000.00818.04
8.2.70.0000.00817.75
8.2.60.0040.00818.03
8.2.50.0060.00318.07
8.2.40.0030.00620.01
8.2.30.0000.00818.07
8.2.20.0000.00817.73
8.2.10.0030.00618.16
8.2.00.0030.00717.70
8.1.280.0040.01525.92
8.1.270.0000.00922.08
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0040.00423.88
8.1.230.0070.00719.16
8.1.220.0080.00017.74
8.1.210.0050.00318.77
8.1.200.0060.00317.47
8.1.190.0040.00417.53
8.1.180.0000.01019.26
8.1.170.0040.00418.66
8.1.160.0070.00022.04
8.1.150.0040.00418.67
8.1.140.0040.00417.52
8.1.130.0030.00317.85
8.1.120.0000.00717.38
8.1.110.0000.00717.43
8.1.100.0070.00017.41
8.1.90.0000.00717.38
8.1.80.0070.00017.38
8.1.70.0000.00817.39
8.1.60.0050.00317.63
8.1.50.0030.00617.45
8.1.40.0060.00317.56
8.1.30.0000.00917.64
8.1.20.0030.00617.67
8.1.10.0030.00617.62
8.1.00.0000.00917.42
8.0.300.0000.00718.77
8.0.290.0030.00417.18
8.0.280.0040.00418.46
8.0.270.0030.00317.15
8.0.260.0030.00317.27
8.0.250.0000.00717.04
8.0.240.0000.00717.09
8.0.230.0000.00717.06
8.0.220.0000.00717.02
8.0.210.0070.00017.01
8.0.200.0040.00416.95
8.0.190.0040.00416.95
8.0.180.0000.00716.91
8.0.170.0000.00716.89
8.0.160.0000.00817.04
8.0.150.0040.00416.94
8.0.140.0000.00716.94
8.0.130.0070.00013.45
8.0.120.0080.00016.93
8.0.110.0030.00517.08
8.0.100.0000.00716.85
8.0.90.0030.00517.05
8.0.80.0130.00316.97
8.0.70.0070.00016.93
8.0.60.0050.00317.05
8.0.50.0040.00416.88
8.0.30.0120.00717.20
8.0.20.0070.01217.46
8.0.10.0000.00817.16
8.0.00.0130.00516.90
7.4.330.0000.00615.00
7.4.320.0080.00016.67
7.4.300.0040.00416.57
7.4.290.0000.00716.53
7.4.280.0000.00716.54
7.4.270.0040.00416.64
7.4.260.0020.00516.64
7.4.250.0000.00816.57
7.4.240.0050.00216.59
7.4.230.0030.00316.73
7.4.220.0090.00916.51
7.4.210.0060.00816.52
7.4.200.0070.00016.64
7.4.190.0030.00316.69
7.4.160.0080.00816.48
7.4.150.0070.01117.40
7.4.140.0130.00717.86
7.4.130.0120.00616.65
7.4.120.0080.00916.66
7.4.110.0070.01116.36
7.4.100.0110.00716.53
7.4.90.0140.00316.64
7.4.80.0080.01419.39
7.4.70.0140.00316.55
7.4.60.0130.00516.66
7.4.50.0030.00616.46
7.4.40.0100.00322.77
7.4.30.0050.01116.42
7.4.00.0080.00615.06
7.3.330.0030.00313.32
7.3.320.0040.00413.41
7.3.310.0030.00316.36
7.3.300.0030.00316.39
7.3.290.0100.01016.54
7.3.280.0090.00616.46
7.3.270.0090.00917.40
7.3.260.0090.01116.71
7.3.250.0130.00816.52
7.3.240.0100.01316.68
7.3.230.0070.01016.39
7.3.210.0110.00516.49
7.3.200.0160.00516.46
7.3.190.0060.01116.43
7.3.180.0080.00816.68
7.3.170.0040.01116.55
7.3.160.0070.01016.56
7.3.120.0080.00614.88
7.3.110.0060.01214.88
7.3.100.0050.01014.89
7.3.90.0070.00714.99
7.3.80.0070.00614.81
7.3.70.0070.00514.91
7.3.60.0050.01114.89
7.3.50.0050.00914.83
7.3.40.0000.01314.92
7.3.30.0050.00514.72
7.3.20.0110.00516.80
7.3.10.0080.00816.67
7.3.00.0060.00616.47
7.2.330.0110.00616.46
7.2.320.0080.00816.59
7.2.310.0170.00016.78
7.2.300.0170.00016.73
7.2.290.0110.00716.86
7.2.250.0000.02015.27
7.2.240.0030.01315.16
7.2.230.0080.00914.99
7.2.220.0070.00715.16
7.2.210.0040.01114.79
7.2.200.0050.00914.89
7.2.190.0050.01215.18
7.2.180.0090.00314.75
7.2.170.0090.00315.10
7.2.160.0100.00715.02
7.2.150.0030.01216.82
7.2.140.0000.01216.99
7.2.130.0030.01517.06
7.2.120.0040.01117.09
7.2.110.0030.00816.93
7.2.100.0060.01016.85
7.2.90.0030.01316.67
7.2.80.0060.00617.14
7.2.70.0030.01216.73
7.2.60.0040.01016.91
7.2.50.0030.00916.92
7.2.40.0030.01616.99
7.2.30.0000.01517.07
7.2.20.0040.00816.96
7.2.10.0040.01116.68
7.2.00.0050.01218.32
7.1.330.0060.01015.89
7.1.320.0060.00715.86
7.1.310.0060.00715.84
7.1.300.0050.01215.82
7.1.290.0080.00715.60
7.1.280.0040.00915.70
7.1.270.0050.00715.73
7.1.260.0090.00615.70
7.1.250.0030.01016.01
7.1.200.0030.01015.85
7.1.100.0070.00418.34
7.1.70.0000.00717.23
7.1.60.0090.01519.46
7.1.50.0000.01116.93
7.1.00.0030.07722.40
7.0.200.1100.00414.59
7.0.140.0030.06722.00
7.0.60.0030.06319.93
7.0.50.0130.07717.83
7.0.40.0070.05720.26
7.0.30.0170.04020.24
7.0.20.0130.04720.16
7.0.10.0270.05320.12
7.0.00.0030.07720.15
5.6.280.0030.07320.80
5.6.210.0130.04020.61
5.6.200.0000.08718.29
5.6.190.0100.08020.38
5.6.180.0270.08020.48
5.6.170.0300.07720.50
5.6.160.0000.04720.57
5.6.150.0030.08318.19
5.6.140.0030.07018.17
5.6.130.0000.04718.29
5.6.120.0030.08721.02
5.6.110.0070.08321.15
5.6.100.0030.08721.01
5.6.90.0030.04021.09
5.6.80.0070.05020.45
5.6.70.3730.03720.29
5.5.350.0070.07720.43
5.5.340.0070.03718.06
5.5.330.0100.07320.19
5.5.320.0200.06320.26
5.5.310.0370.06720.24
5.5.300.0070.08017.96
5.5.290.0030.08317.97
5.5.280.0000.08020.99
5.5.270.0070.05320.90
5.5.260.0000.06720.80
5.5.250.0100.05320.71
5.5.240.0000.04020.27
5.4.450.0230.08019.55
5.4.440.0130.08019.49
5.4.430.0330.06319.48
5.4.420.0230.06319.45
5.4.410.0330.03019.34
5.4.400.0100.06319.14
5.4.390.0230.06319.08
5.4.380.0230.07319.22
5.4.370.0170.06019.13
5.4.360.0230.06719.10
5.4.350.0200.07019.31
5.4.340.0230.07019.31
5.4.320.0330.06318.94
5.4.310.0130.05319.25
5.4.300.0200.06719.21
5.4.290.0100.08319.22
5.4.280.0170.07019.08
5.4.270.0130.07018.85
5.4.260.0170.04019.13
5.4.250.0170.04018.84
5.4.240.0170.05718.98
5.4.230.0130.05019.21
5.4.220.0200.07019.19
5.4.210.0200.04318.84
5.4.200.0230.05719.15
5.4.190.0070.04719.21
5.4.180.0230.07318.86
5.4.170.0270.06718.94
5.4.160.0230.05718.85
5.4.150.0170.05319.20
5.4.140.0200.07316.41
5.4.130.0170.04016.39
5.4.120.0170.03316.56
5.4.110.0130.04716.50
5.4.100.0200.06716.24
5.4.90.0300.05716.23
5.4.80.0200.07016.57
5.4.70.0230.05716.55
5.4.60.0200.03716.33
5.4.50.0270.05016.19
5.4.40.0230.05316.26
5.4.30.0200.07016.25
5.4.20.0130.08016.34
5.4.10.0330.04316.53
5.4.00.0270.03715.78
5.3.290.0270.06314.67
5.3.280.0170.04714.58
5.3.270.0170.07714.61
5.3.260.0200.06314.61
5.3.250.0070.04714.52
5.3.240.0100.05014.66
5.3.230.0170.05014.53
5.3.220.0200.03314.65
5.3.210.0130.05014.48
5.3.200.0170.06714.70
5.3.190.0200.06714.56
5.3.180.0170.07714.55
5.3.170.0230.06714.73
5.3.160.0170.04714.73
5.3.150.0170.08014.66
5.3.140.0200.05714.54
5.3.130.0100.05314.57
5.3.120.0170.08014.64
5.3.110.0270.06714.57
5.3.100.0130.07713.95
5.3.90.0170.04314.07
5.3.80.0170.04014.08
5.3.70.0170.04714.03
5.3.60.0200.05713.93
5.3.50.0230.03713.87
5.3.40.0230.05313.87
5.3.30.0230.04313.93
5.3.20.0170.07013.61
5.3.10.0200.05713.66
5.3.00.0230.04713.73
5.2.170.0130.03012.12
5.2.160.0200.03012.12
5.2.150.0230.03012.12
5.2.140.0130.04312.12
5.2.130.0100.05712.12
5.2.120.0170.05312.12
5.2.110.0200.05712.12
5.2.100.0170.03312.12
5.2.90.0170.04012.12
5.2.80.0100.06712.12
5.2.70.0130.04012.12
5.2.60.0170.05712.12
5.2.50.0130.05312.12
5.2.40.0170.03712.12
5.2.30.0170.05712.12
5.2.20.0100.05712.12
5.2.10.0170.05312.12
5.2.00.0170.05312.12
5.1.60.0100.03312.12
5.1.50.0130.04712.12
5.1.40.0100.03712.12
5.1.30.0130.05712.12
5.1.20.0100.05712.12
5.1.10.0130.04312.12
5.1.00.0200.03312.12
5.0.50.0130.03012.12
5.0.40.0100.01712.12
5.0.30.0170.05712.12
5.0.20.0100.04012.12
5.0.10.0070.04312.12
5.0.00.0030.04312.12
4.4.90.0070.02012.12
4.4.80.0070.03712.12
4.4.70.0100.03312.12
4.4.60.0070.03312.12
4.4.50.0030.02312.12
4.4.40.0100.02712.12
4.4.30.0030.03712.12
4.4.20.0070.03712.12
4.4.10.0070.03712.12
4.4.00.0070.04712.12
4.3.110.0070.03012.12
4.3.100.0030.02312.12
4.3.90.0030.03312.12
4.3.80.0070.03712.12
4.3.70.0070.03712.12
4.3.60.0070.03312.12
4.3.50.0170.02712.12
4.3.40.0030.05712.12
4.3.30.0000.04012.12
4.3.20.0000.03312.12
4.3.10.0130.02712.12
4.3.00.0070.02712.12

preferences:
40.31 ms | 401 KiB | 5 Q