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->callback = '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.0070.00716.62
8.3.50.0150.00721.95
8.3.40.0180.00618.71
8.3.30.0060.00819.03
8.3.20.0050.00320.20
8.3.10.0040.00423.48
8.3.00.0040.00419.13
8.2.180.0110.00718.28
8.2.170.0060.00922.96
8.2.160.0070.00720.39
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0080.01226.16
8.2.120.0040.00422.05
8.2.110.0030.00622.20
8.2.100.0080.00317.84
8.2.90.0050.00319.22
8.2.80.0000.00817.97
8.2.70.0050.00317.75
8.2.60.0050.00317.93
8.2.50.0050.00318.07
8.2.40.0040.00420.01
8.2.30.0040.00418.08
8.2.20.0000.00717.71
8.2.10.0040.00419.83
8.2.00.0000.01017.77
8.1.280.0160.00025.92
8.1.270.0040.00423.95
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0070.01023.80
8.1.230.0120.00019.15
8.1.220.0040.00417.74
8.1.210.0050.00518.77
8.1.200.0100.00017.48
8.1.190.0080.00017.43
8.1.180.0030.00618.10
8.1.170.0030.00618.58
8.1.160.0050.00222.05
8.1.150.0070.00318.63
8.1.140.0000.00717.48
8.1.130.0030.00317.73
8.1.120.0000.00717.50
8.1.110.0000.01017.46
8.1.100.0040.00417.51
8.1.90.0080.00017.38
8.1.80.0000.00717.38
8.1.70.0030.00317.38
8.1.60.0040.00417.54
8.1.50.0050.00317.55
8.1.40.0000.00817.54
8.1.30.0050.00317.60
8.1.20.0000.00817.66
8.1.10.0000.00817.63
8.1.00.0000.00717.43
8.0.300.0040.00420.80
8.0.290.0050.00217.30
8.0.280.0000.00818.36
8.0.270.0000.00717.18
8.0.260.0000.00617.29
8.0.250.0030.00316.96
8.0.240.0000.00816.95
8.0.230.0000.00717.01
8.0.220.0000.00716.90
8.0.210.0000.00716.88
8.0.200.0070.00017.05
8.0.190.0030.00517.08
8.0.180.0000.00716.96
8.0.170.0000.00816.91
8.0.160.0080.00016.96
8.0.150.0040.00416.84
8.0.140.0040.00416.93
8.0.130.0070.00013.48
8.0.120.0040.00416.89
8.0.110.0000.00716.98
8.0.100.0040.00417.05
8.0.90.0040.00416.84
8.0.80.0060.01617.05
8.0.70.0030.00516.94
8.0.60.0050.00316.97
8.0.50.0030.00516.89
8.0.30.0100.01217.20
8.0.20.0160.00417.40
8.0.10.0000.00817.04
8.0.00.0060.01116.78
7.4.330.0030.00315.00
7.4.320.0060.00016.58
7.4.300.0060.00016.54
7.4.290.0000.00716.43
7.4.280.0000.00716.54
7.4.270.0000.00816.53
7.4.260.0080.00016.50
7.4.250.0050.00216.36
7.4.240.0040.00316.63
7.4.230.0070.00016.64
7.4.220.0060.01216.72
7.4.210.0100.00516.69
7.4.200.0000.00816.57
7.4.190.0000.00716.67
7.4.160.0060.01016.44
7.4.150.0120.00517.40
7.4.140.0110.00817.86
7.4.130.0100.00716.49
7.4.120.0090.00716.60
7.4.110.0040.01816.65
7.4.100.0060.01216.64
7.4.90.0090.00916.76
7.4.80.0060.01319.39
7.4.70.0100.01016.52
7.4.60.0140.00516.50
7.4.50.0050.00016.54
7.4.40.0060.01022.77
7.4.30.0060.01016.57
7.4.00.0090.00715.02
7.3.330.0060.00013.33
7.3.320.0050.00013.29
7.3.310.0050.00316.49
7.3.300.0030.00516.46
7.3.290.0060.00916.44
7.3.280.0090.00916.44
7.3.270.0100.00617.40
7.3.260.0150.00416.74
7.3.250.0140.00316.49
7.3.240.0150.00616.51
7.3.230.0210.00316.46
7.3.210.0130.00316.39
7.3.200.0040.01719.39
7.3.190.0150.00616.32
7.3.180.0040.01216.64
7.3.170.0070.00916.43
7.3.160.0030.01216.52
7.3.120.0100.00614.86
7.3.110.0040.01215.01
7.3.100.0130.00314.87
7.3.90.0060.00814.98
7.3.80.0030.01314.84
7.3.70.0080.00314.94
7.3.60.0070.00714.59
7.3.50.0040.00414.79
7.3.40.0030.00615.01
7.3.30.0040.00814.70
7.3.20.0060.00316.79
7.3.10.0060.01116.74
7.3.00.0050.00916.71
7.2.330.0100.00816.71
7.2.320.0060.01216.86
7.2.310.0100.01016.88
7.2.300.0100.00716.80
7.2.290.0090.00916.59
7.2.250.0070.01015.17
7.2.240.0070.01314.88
7.2.230.0090.00915.07
7.2.220.0140.00315.25
7.2.210.0090.00614.87
7.2.200.0060.00615.16
7.2.190.0090.00615.10
7.2.180.0000.01215.20
7.2.170.0040.00815.05
7.2.130.0040.01116.96
7.2.120.0100.00617.00
7.2.110.0090.00517.00
7.2.100.0020.01416.88
7.2.90.0020.00917.04
7.2.80.0070.00916.89
7.2.70.0090.00417.01
7.2.60.0140.00716.82
7.2.50.0080.00616.85
7.2.40.0070.00916.83
7.2.30.0110.00616.82
7.2.20.0090.00416.88
7.2.10.0050.00916.88
7.2.00.0040.01017.73
7.1.330.0150.00315.79
7.1.320.0090.00615.82
7.1.310.0040.01215.88
7.1.300.0080.00415.84
7.1.290.0080.00315.86
7.1.280.0060.00615.74
7.1.270.0100.00615.69
7.1.260.0070.00415.79
7.1.250.0060.00715.68
7.1.200.0030.00915.78
7.1.100.0060.00917.92
7.1.70.0030.01216.71
7.1.60.0030.02319.46
7.1.50.0200.01734.68
7.1.00.0000.08022.41
7.0.200.0040.00416.78
7.0.140.0000.07722.10
7.0.110.0070.07320.07
7.0.100.0170.07320.13
7.0.90.0030.08320.09
7.0.80.0100.07320.02
7.0.70.0130.03720.10
7.0.60.0100.06320.06
7.0.50.0030.08020.46
7.0.40.0030.05020.20
7.0.30.0100.03720.04
7.0.20.0030.04320.03
7.0.10.0030.04320.08
7.0.00.0100.03720.04
5.6.280.0030.07320.91
5.6.260.0170.07720.64
5.6.250.0070.04720.66
5.6.240.0130.08020.56
5.6.230.0130.08020.86
5.6.220.0100.07020.55
5.6.210.0070.08320.59
5.6.200.0030.05321.29
5.6.190.0070.06721.19
5.6.180.0070.04020.99
5.6.170.0070.03721.03
5.6.160.0070.04321.00
5.6.150.0100.03721.12
5.6.140.0030.04320.99
5.6.130.0100.05021.27
5.6.120.0070.04021.13
5.6.110.0030.04021.26
5.6.100.0070.04021.29
5.6.90.0030.04021.04
5.6.80.0070.03720.35
5.6.70.0030.04020.53
5.6.60.0070.03720.43
5.6.50.0070.03720.66
5.6.40.0030.05020.29
5.6.30.0030.04020.55
5.6.20.0070.04020.32
5.6.10.0000.04720.50
5.6.00.0030.04020.34
5.5.380.0200.06720.52
5.5.370.0070.08020.30
5.5.360.0170.05020.36
5.5.350.0100.08020.46
5.5.340.0070.07720.95
5.5.330.0000.05020.71
5.5.320.0030.04320.70
5.5.310.0170.03320.95
5.5.300.0070.03721.00
5.5.290.0000.05020.89
5.5.280.0030.04320.97
5.5.270.0100.05720.82
5.5.260.0000.04320.81
5.5.250.0070.04320.59
5.5.240.0030.04020.17
5.5.230.0070.04020.13
5.5.220.0030.05320.16
5.5.210.0070.04020.43
5.5.200.0030.03720.31
5.5.190.0000.04720.30
5.5.180.0070.03720.13
5.5.160.0030.05020.31
5.5.150.0000.04020.31
5.5.140.0170.03720.14
5.5.130.0130.05020.32
5.5.120.0030.04020.23
5.5.110.0000.04320.19
5.5.100.0070.04720.06
5.5.90.0070.03320.20
5.5.80.0100.03020.20
5.5.70.0000.04320.28
5.5.60.0070.03320.17
5.5.50.0100.06720.19
5.5.40.0070.07720.10
5.5.30.0070.07720.16
5.5.20.0070.07020.16
5.5.10.0130.06720.07
5.5.00.0000.07320.23
5.4.450.0130.06319.64
5.4.440.0030.05019.34
5.4.430.0130.03319.48
5.4.420.0030.04019.65
5.4.410.0000.04719.19
5.4.400.0000.04019.19
5.4.390.0100.07719.14
5.4.380.0030.04318.97
5.4.370.0000.04019.18
5.4.360.0070.04719.23
5.4.350.0030.04019.00
5.4.340.0000.04019.02
5.4.320.0000.04319.03
5.4.310.0000.04019.02
5.4.300.0130.06719.23
5.4.290.0030.03719.23
5.4.280.0030.04718.95
5.4.270.0100.05018.99
5.4.260.0030.03719.18
5.4.250.0070.03319.30
5.4.240.0070.03319.00
5.4.230.0030.05019.22
5.4.220.0030.04019.22
5.4.210.0230.05719.30
5.4.200.0030.08019.13
5.4.190.0070.08019.17
5.4.180.0100.07019.13
5.4.170.0070.07719.17
5.4.160.0030.07718.97
5.4.150.0070.06319.01
5.4.140.0030.07716.61
5.4.130.0030.04316.36
5.4.120.0070.07016.59
5.4.110.0070.07316.59
5.4.100.0170.06316.50
5.4.90.0070.07316.46
5.4.80.0030.07316.30
5.4.70.0030.07316.45
5.4.60.0070.07316.57
5.4.50.0130.08316.49
5.4.40.0030.07716.29
5.4.30.0070.07316.18
5.4.20.0100.07316.62
5.4.10.0070.04316.23
5.4.00.0030.08015.78
5.3.290.0000.04014.68
5.3.280.0070.04714.74
5.3.270.0100.07014.76
5.3.260.0030.05314.64
5.3.250.0000.06014.70
5.3.240.0070.07314.70
5.3.230.0070.07714.70
5.3.220.0070.07714.59
5.3.210.0000.08314.65
5.3.200.0070.07314.55
5.3.190.0070.07314.53
5.3.180.0000.05014.66
5.3.170.0030.07314.70
5.3.160.0070.07314.66
5.3.150.0070.07714.71
5.3.140.0000.08014.58
5.3.130.0100.06714.52
5.3.120.0030.07714.56
5.3.110.0130.07314.68
5.3.100.0000.08314.00
5.3.90.0100.06714.16
5.3.80.0100.05014.04
5.3.70.0030.07714.16
5.3.60.0100.07714.14
5.3.50.0000.05714.10
5.3.40.0070.07714.02
5.3.30.0070.07013.93
5.3.20.0100.06713.70
5.3.10.0000.04713.68
5.3.00.0170.03313.66
5.2.170.0100.05312.34
5.2.160.0070.04712.34
5.2.150.0030.06312.34
5.2.140.0070.06012.34
5.2.130.0030.06012.34
5.2.120.0070.06012.34
5.2.110.0000.06712.34
5.2.100.0030.06712.34
5.2.90.0070.08012.34
5.2.80.0070.05312.34
5.2.70.0100.05312.34
5.2.60.0100.03312.34
5.2.50.0030.06712.34
5.2.40.0070.03012.34
5.2.30.0030.05712.34
5.2.20.0000.04012.34
5.2.10.0030.06012.34
5.2.00.0030.05012.34
5.1.60.0200.03712.34
5.1.50.0030.05312.34
5.1.40.0130.03712.34
5.1.30.0000.05712.34
5.1.20.0030.04012.34
5.1.10.0100.05312.34
5.1.00.0030.04712.34
5.0.50.0070.04312.34
5.0.40.0100.03712.34
5.0.30.0030.06712.34
5.0.20.0030.02712.34
5.0.10.0030.05312.34
5.0.00.0070.06312.34
4.4.90.0000.03712.34
4.4.80.0030.03712.34
4.4.70.0030.03712.34
4.4.60.0030.02712.34
4.4.50.0000.04012.34
4.4.40.0030.05312.34
4.4.30.0000.03712.34
4.4.20.0000.03712.34
4.4.10.0000.02012.34
4.4.00.0000.05312.34
4.3.110.0000.02712.34
4.3.100.0000.02712.34
4.3.90.0000.03712.34
4.3.80.0000.02712.34
4.3.70.0000.01712.34
4.3.60.0030.03312.34
4.3.50.0030.03312.34
4.3.40.0030.04712.34
4.3.30.0000.02012.34
4.3.20.0000.03712.34
4.3.10.0000.02012.34
4.3.00.0000.03712.34

preferences:
51.48 ms | 401 KiB | 5 Q