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]] , 'hi'); // 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.0130.00722.04
8.3.40.0120.00618.97
8.3.30.0100.00318.98
8.3.20.0050.00320.33
8.3.10.0070.00023.64
8.3.00.0040.00419.38
8.2.180.0100.01018.54
8.2.170.0130.00722.96
8.2.160.0070.00720.57
8.2.150.0070.00024.18
8.2.140.0060.00324.66
8.2.130.0100.00726.16
8.2.120.0070.00021.10
8.2.110.0100.00022.25
8.2.100.0030.00917.84
8.2.90.0000.00819.33
8.2.80.0030.00518.04
8.2.70.0040.00417.63
8.2.60.0080.00018.01
8.2.50.0000.00818.07
8.2.40.0030.00720.07
8.2.30.0050.00318.16
8.2.20.0050.00317.90
8.2.10.0000.00818.18
8.2.00.0070.00317.71
8.1.280.0100.01325.92
8.1.270.0090.00023.90
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0040.00424.00
8.1.230.0030.00819.15
8.1.220.0000.00917.78
8.1.210.0000.00818.77
8.1.200.0000.00917.38
8.1.190.0060.00317.53
8.1.180.0000.00818.89
8.1.170.0060.00318.46
8.1.160.0000.00721.98
8.1.150.0070.00318.67
8.1.140.0000.00717.47
8.1.130.0000.00717.84
8.1.120.0000.00817.49
8.1.110.0060.00317.40
8.1.100.0000.00717.57
8.1.90.0050.00217.54
8.1.80.0000.00817.51
8.1.70.0030.00317.41
8.1.60.0000.00817.65
8.1.50.0000.00817.49
8.1.40.0000.00917.46
8.1.30.0040.00417.61
8.1.20.0040.00417.71
8.1.10.0050.00217.58
8.1.00.0000.00717.47
8.0.300.0030.00618.77
8.0.290.0040.00417.18
8.0.280.0050.00318.48
8.0.270.0000.00717.26
8.0.260.0000.00617.28
8.0.250.0030.00317.08
8.0.240.0050.00216.94
8.0.230.0000.00716.96
8.0.220.0030.00316.89
8.0.210.0070.00016.97
8.0.200.0030.00316.98
8.0.190.0060.00317.01
8.0.180.0040.00416.89
8.0.170.0070.00017.02
8.0.160.0070.00016.95
8.0.150.0000.00816.91
8.0.140.0000.00816.95
8.0.130.0030.00313.40
8.0.120.0050.00316.84
8.0.110.0000.00716.95
8.0.100.0070.00016.88
8.0.90.0050.00316.88
8.0.80.0060.00916.97
8.0.70.0000.00716.98
8.0.60.0050.00217.10
8.0.50.0000.00817.01
8.0.30.0090.00917.14
8.0.20.0130.00517.42
8.0.10.0050.00216.92
8.0.00.0080.01016.76
7.4.330.0070.00015.00
7.4.320.0060.00016.53
7.4.300.0060.00016.56
7.4.290.0040.00416.61
7.4.280.0090.00016.64
7.4.270.0040.00416.44
7.4.260.0070.00016.54
7.4.250.0030.00616.61
7.4.240.0040.00416.55
7.4.230.0000.00716.66
7.4.220.0120.00616.59
7.4.210.0110.00716.64
7.4.200.0000.00716.64
7.4.190.0030.00316.59
7.4.160.0070.01016.49
7.4.150.0120.01217.40
7.4.140.0100.00717.86
7.4.130.0100.00616.61
7.4.120.0090.00816.56
7.4.110.0140.00416.54
7.4.100.0040.01516.63
7.4.90.0080.00816.50
7.4.80.0030.01719.39
7.4.70.0070.01116.77
7.4.60.0060.01216.42
7.4.50.0080.00016.68
7.4.40.0080.00522.77
7.4.30.0130.00316.69
7.4.00.0030.01314.96
7.3.330.0000.00613.48
7.3.320.0030.00313.31
7.3.310.0040.00416.50
7.3.300.0000.00716.36
7.3.290.0030.01116.46
7.3.280.0080.00916.46
7.3.270.0070.01317.40
7.3.260.0160.00616.54
7.3.250.0080.00916.51
7.3.240.0140.00316.42
7.3.230.0080.00816.64
7.3.210.0120.00616.41
7.3.200.0040.01216.65
7.3.190.0090.00916.61
7.3.180.0040.01216.46
7.3.170.0030.01716.39
7.3.160.0090.00616.53
7.3.120.0060.00914.68
7.2.330.0170.00016.57
7.2.320.0120.00416.80
7.2.310.0060.00916.85
7.2.300.0060.01216.70
7.2.290.0140.00716.88
7.2.60.0060.01017.16
7.2.50.0000.01316.82
7.2.00.0030.01219.27
7.1.200.0060.00615.95
7.1.70.0000.00716.93
7.1.60.0100.01319.46
7.1.50.0040.00716.75
7.1.00.0100.07022.31
7.0.200.0000.00916.68
7.0.140.0000.07722.00
7.0.100.0000.05721.93
7.0.90.0100.08319.90
7.0.80.0170.05320.03
7.0.70.0100.08319.90
7.0.60.0070.08319.94
7.0.50.0230.03720.34
7.0.40.0070.04320.08
7.0.30.0030.08720.09
7.0.20.0070.07720.07
7.0.10.0070.06320.09
7.0.00.0100.07020.09
5.6.280.0130.06721.08
5.6.250.0100.05320.55
5.6.240.0100.08720.67
5.6.230.0170.06320.63
5.6.220.0030.08020.66
5.6.210.0100.07720.47
5.6.200.0030.05021.05
5.6.190.0130.06321.14
5.6.180.0100.05721.02
5.6.170.0070.07721.02
5.6.160.0070.06721.01
5.6.150.0000.06721.03
5.6.140.0130.07721.06
5.6.130.0070.08021.14
5.6.120.0030.08320.96
5.6.110.0030.08320.96
5.6.100.0030.07721.04
5.6.90.0070.06021.07
5.6.80.0100.07020.33
5.6.70.0100.05720.49
5.6.60.0100.07320.31
5.6.50.0000.04320.47
5.6.40.0030.06720.43
5.6.30.0030.04320.32
5.6.20.0100.07720.32
5.6.10.0070.03320.53
5.6.00.0070.04320.43
5.5.380.0070.06320.42
5.5.370.0070.07020.32
5.5.360.0030.04320.43
5.5.350.0070.04720.33
5.5.340.0030.04320.91
5.5.330.0100.07320.80
5.5.320.0100.07720.81
5.5.310.0030.07020.66
5.5.300.0100.04020.80
5.5.290.0070.07020.77
5.5.280.0170.07320.82
5.5.270.0130.08020.84
5.5.260.0130.07320.85
5.5.250.0200.06320.72
5.5.240.0030.04020.19
5.5.230.0130.07020.03
5.5.220.0130.06020.11
5.5.210.0070.08320.27
5.5.200.0000.08720.14
5.5.190.0170.07320.21
5.5.180.0000.04020.01
5.5.160.0100.07720.16
5.5.150.0070.06020.21
5.5.140.0000.04720.19
5.5.130.0030.04020.30
5.5.120.0070.03720.18
5.5.110.0100.03320.24
5.5.100.0070.07720.19
5.5.90.0100.03020.09
5.5.80.0070.08020.12
5.5.70.0070.07720.17
5.5.60.0030.04320.09
5.5.50.0030.07020.07
5.5.40.0070.04320.04
5.5.30.0030.07720.15
5.5.20.0070.03319.95
5.5.10.0030.05319.99
5.5.00.0000.04020.06
5.4.450.0100.08319.54
5.4.440.0000.04319.58
5.4.430.0070.05719.17
5.4.420.0030.04019.22
5.4.410.0000.04319.32
5.4.400.0030.06719.08
5.4.390.0070.03718.89
5.4.380.0030.08719.13
5.4.370.0030.06319.18
5.4.360.0130.06318.95
5.4.350.0070.04319.16
5.4.340.0200.06718.96
5.4.320.0030.08019.00
5.4.310.0130.06018.85
5.4.300.0030.04019.21
5.4.290.0130.03719.02
5.4.280.0130.07319.04
5.4.270.0000.04019.08
5.4.260.0070.07719.08
5.4.250.0100.05318.84
5.4.240.0000.04719.13
5.4.230.0130.06019.02
5.4.220.0000.05019.03
5.4.210.0070.05318.89
5.4.200.0100.05018.84
5.4.190.0130.06719.02
5.4.180.0070.03319.03
5.4.170.0030.06018.86
5.4.160.0030.07319.11
5.4.150.0070.07718.83
5.4.140.0100.02716.48
5.4.130.0070.06016.38
5.4.120.0030.03716.23
5.4.110.0030.03716.48
5.4.100.0000.04016.54
5.4.90.0100.07016.42
5.4.80.0070.06016.46
5.4.70.0070.05016.50
5.4.60.0070.05716.49
5.4.50.0130.07016.46
5.4.40.0130.06016.34
5.4.30.0070.06716.40
5.4.20.0130.06316.32
5.4.10.0070.06016.43
5.4.00.0030.03315.85
5.3.290.0030.08014.70
5.3.280.0170.04314.70
5.3.270.0070.03314.61
5.3.260.0030.05714.62
5.3.250.0000.04714.60
5.3.240.0030.08014.54
5.3.230.0030.03714.67
5.3.220.0100.07314.63
5.3.210.0030.03714.58
5.3.200.0130.06314.66
5.3.190.0070.07714.59
5.3.180.0100.07314.64
5.3.170.0070.07014.63
5.3.160.0130.06714.56
5.3.150.0030.05714.61
5.3.140.0070.03714.56
5.3.130.0130.06714.67
5.3.120.0200.06014.49
5.3.110.0130.03314.52
5.3.100.0070.03714.01
5.3.90.0070.06014.01
5.3.80.0070.07313.93
5.3.70.0130.06713.93
5.3.60.0070.07714.04
5.3.50.0030.06314.02
5.3.40.0100.03014.02
5.3.30.0100.06314.03
5.3.20.0000.03713.72
5.3.10.0030.03713.59
5.3.00.0030.04313.58
5.2.170.0000.03311.82
5.2.160.0030.06011.82
5.2.150.0070.02711.82
5.2.140.0000.04011.82
5.2.130.0070.03711.82
5.2.120.0030.06311.82
5.2.110.0000.03011.82
5.2.100.0030.06711.82
5.2.90.0000.05311.82
5.2.80.0100.05011.82
5.2.70.0100.06311.82
5.2.60.0100.05011.82
5.2.50.0030.06011.82
5.2.40.0030.04011.82
5.2.30.0030.04011.82
5.2.20.0030.06011.82
5.2.10.0000.03011.82
5.2.00.0030.02711.82
5.1.60.0070.02011.82
5.1.50.0030.02311.82
5.1.40.0000.02711.82
5.1.30.0000.02711.82
5.1.20.0030.02711.82
5.1.10.0000.02711.82
5.1.00.0000.02711.82
5.0.50.0030.01711.82
5.0.40.0000.02011.82
5.0.30.0000.03311.82
5.0.20.0030.01711.82
5.0.10.0000.02011.82
5.0.00.0030.04311.82
4.4.90.0070.03011.82
4.4.80.0030.01711.82
4.4.70.0030.03311.82
4.4.60.0000.01711.82
4.4.50.0000.01711.82
4.4.40.0000.03011.82
4.4.30.0030.01311.82
4.4.20.0000.01711.82
4.4.10.0030.01311.82
4.4.00.0030.02311.82
4.3.110.0030.01311.82
4.3.100.0000.01311.82
4.3.90.0000.01711.82
4.3.80.0070.04711.82
4.3.70.0000.01711.82
4.3.60.0000.03311.82
4.3.50.0000.02711.82
4.3.40.0000.04011.82
4.3.30.0030.03311.82
4.3.20.0000.02311.82
4.3.10.0030.02711.82
4.3.00.0000.02011.82

preferences:
53.75 ms | 401 KiB | 5 Q