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[$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.0110.00416.63
8.3.50.0090.00722.00
8.3.40.0100.00718.79
8.3.30.0110.00419.04
8.3.20.0040.00420.29
8.3.10.0070.00023.65
8.3.00.0080.00019.51
8.2.180.0120.00918.29
8.2.170.0160.00022.96
8.2.160.0100.00320.21
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0110.00726.16
8.2.120.0000.00722.30
8.2.110.0060.00322.04
8.2.100.0000.01217.78
8.2.90.0030.00517.97
8.2.80.0000.00817.97
8.2.70.0030.00517.63
8.2.60.0080.00018.05
8.2.50.0000.00818.07
8.2.40.0060.00319.91
8.2.30.0040.00418.16
8.2.20.0000.00817.75
8.2.10.0050.00318.12
8.2.00.0030.00717.84
8.1.280.0070.00725.92
8.1.270.0080.00023.82
8.1.260.0030.00626.35
8.1.250.0070.00028.09
8.1.240.0060.00322.54
8.1.230.0090.00320.91
8.1.220.0050.00317.78
8.1.210.0080.00018.87
8.1.200.0030.00617.35
8.1.190.0090.00017.51
8.1.180.0040.00419.14
8.1.170.0000.00818.50
8.1.160.0040.00421.98
8.1.150.0060.00318.63
8.1.140.0020.00517.40
8.1.130.0040.00417.86
8.1.120.0000.00717.51
8.1.110.0060.00317.34
8.1.100.0040.00417.45
8.1.90.0070.00017.51
8.1.80.0070.00017.47
8.1.70.0000.00717.42
8.1.60.0040.00417.61
8.1.50.0000.00917.57
8.1.40.0000.00717.54
8.1.30.0050.00317.66
8.1.20.0000.00917.68
8.1.10.0070.00017.47
8.1.00.0000.00817.61
8.0.300.0000.00819.93
8.0.290.0040.00417.05
8.0.280.0030.00318.48
8.0.270.0000.00717.17
8.0.260.0070.00017.20
8.0.250.0080.00017.05
8.0.240.0030.00617.00
8.0.230.0080.00017.02
8.0.220.0000.00716.90
8.0.210.0070.00017.03
8.0.200.0030.00317.02
8.0.190.0040.00417.05
8.0.180.0070.00017.02
8.0.170.0040.00417.04
8.0.160.0070.00017.01
8.0.150.0070.00016.84
8.0.140.0040.00416.86
8.0.130.0030.00313.38
8.0.120.0090.00016.96
8.0.110.0030.00516.93
8.0.100.0000.00716.88
8.0.90.0040.00416.84
8.0.80.0070.00716.98
8.0.70.0050.00217.11
8.0.60.0040.00416.88
8.0.50.0000.00717.09
8.0.30.0050.01617.33
8.0.20.0100.00917.40
8.0.10.0040.00417.12
8.0.00.0130.00516.78
7.4.330.0070.00015.00
7.4.320.0030.00316.68
7.4.300.0000.00616.52
7.4.290.0000.00716.46
7.4.280.0080.00016.66
7.4.270.0000.00816.55
7.4.260.0000.00716.55
7.4.250.0060.00316.54
7.4.240.0050.00216.65
7.4.230.0000.00716.45
7.4.220.0110.00816.64
7.4.210.0080.00816.57
7.4.200.0070.00016.73
7.4.190.0030.00316.41
7.4.160.0130.00316.56
7.4.150.0120.00617.40
7.4.140.0100.01417.86
7.4.130.0150.00416.53
7.4.120.0070.01016.59
7.4.110.0130.00416.46
7.4.100.0120.00616.75
7.4.90.0030.01416.52
7.4.80.0060.01519.39
7.4.70.0080.00816.62
7.4.60.0110.00616.47
7.4.50.0040.00416.64
7.4.40.0060.00622.77
7.4.30.0090.01216.66
7.4.00.0100.00315.24
7.3.330.0070.00013.39
7.3.320.0030.00313.40
7.3.310.0050.00316.50
7.3.300.0040.00416.36
7.3.290.0180.00316.46
7.3.280.0080.00916.44
7.3.270.0070.01517.40
7.3.260.0110.00716.53
7.3.250.0100.00716.58
7.3.240.0080.00816.46
7.3.230.0030.01316.39
7.3.210.0100.01416.46
7.3.200.0210.00016.39
7.3.190.0060.01116.75
7.3.180.0120.00316.43
7.3.170.0060.00916.42
7.3.160.0080.00816.37
7.3.120.0130.00314.94
7.3.10.0080.00316.70
7.3.00.0180.00016.45
7.2.330.0050.01316.89
7.2.320.0060.01116.81
7.2.310.0040.01216.64
7.2.300.0060.01116.60
7.2.290.0060.01216.87
7.2.130.0030.01316.84
7.2.120.0140.01416.68
7.2.110.0260.00916.66
7.2.100.0160.00616.93
7.2.90.0110.00816.80
7.2.80.0110.01116.77
7.2.70.0090.00616.75
7.2.60.0080.00716.63
7.2.50.0100.00316.82
7.2.40.0000.01116.65
7.2.30.0160.00017.01
7.2.20.0030.01016.96
7.2.10.0000.01016.90
7.2.00.0020.00818.01
7.1.250.0130.00915.77
7.1.200.0070.00715.84
7.1.100.0080.00418.01
7.1.70.0080.00316.63
7.1.60.0100.01419.46
7.1.50.0030.00916.96
7.1.00.0070.07322.31
7.0.200.0070.00316.70
7.0.140.0000.07322.08
7.0.60.0070.09019.89
7.0.50.0070.03717.87
7.0.40.0100.04020.27
7.0.30.0430.04320.10
7.0.20.0200.04720.10
7.0.10.0070.04020.15
7.0.00.0030.08320.23
5.6.280.0030.07320.80
5.6.210.0070.09020.77
5.6.200.0030.07018.29
5.6.190.0030.06020.48
5.6.180.0470.05020.55
5.6.170.0530.05320.59
5.6.160.0130.05020.62
5.6.150.0170.06718.29
5.6.140.0070.07318.17
5.6.130.0030.05318.16
5.6.120.0200.07721.00
5.6.110.0100.07021.10
5.6.100.0230.06721.10
5.6.90.0130.07321.11
5.6.80.0130.07320.41
5.6.70.4370.04020.52
5.5.350.0070.07720.54
5.5.340.0070.07717.93
5.5.330.0130.05720.43
5.5.320.0330.06320.27
5.5.310.0230.04020.30
5.5.300.0130.08018.06
5.5.290.0070.07717.98
5.5.280.0030.06320.89
5.5.270.0070.04020.79
5.5.260.0000.09320.87
5.5.250.0030.07020.63
5.5.240.0100.07020.13
5.4.450.0800.04719.58
5.4.440.0700.06719.30
5.4.430.0600.05319.46
5.4.420.0930.06719.52
5.4.410.0530.06719.36
5.4.400.0600.05019.05
5.4.390.0630.06719.20
5.4.380.0470.04318.54
5.4.370.0470.05718.80
5.4.360.0530.05718.60
5.4.350.0570.07018.71
5.4.340.0270.05318.61
5.4.320.0040.04312.52
5.4.310.0050.03812.51
5.4.300.0080.03512.51
5.4.290.0060.05612.50
5.4.280.0110.04812.39
5.4.270.0130.04912.39
5.4.260.0090.05312.40
5.4.250.0070.05412.39
5.4.240.0080.05212.39
5.4.230.0080.05312.39
5.4.220.0080.05212.39
5.4.210.0090.05212.39
5.4.200.0060.04412.39
5.4.190.0040.05012.38
5.4.180.0100.03912.39
5.4.170.0100.04512.39
5.4.160.0090.05012.38
5.4.150.0100.04712.38
5.4.140.0090.05312.06
5.4.130.0110.06512.05
5.4.120.0080.05412.01
5.4.110.0110.05012.00
5.4.100.0120.04612.00
5.4.90.0100.05112.01
5.4.80.0100.04312.00
5.4.70.0040.03812.00
5.4.60.0080.04812.00
5.4.50.0070.04512.00
5.4.40.0090.04511.99
5.4.30.0100.05311.98
5.4.20.0060.05811.99
5.4.10.0060.03511.98
5.4.00.0140.06011.48
5.3.290.0070.04412.80
5.3.280.0210.10112.71
5.3.270.0100.05112.72
5.3.260.0040.04612.71
5.3.250.0080.05612.72
5.3.240.0030.05912.72
5.3.230.0090.06512.71
5.3.220.0120.05812.68
5.3.210.0140.06612.68
5.3.200.0120.05912.68
5.3.190.0070.05712.67
5.3.180.0080.05412.67
5.3.170.0190.09012.67
5.3.160.0140.05412.68
5.3.150.0120.07912.67
5.3.140.0130.05012.66
5.3.130.0200.06212.66
5.3.120.0120.06512.66
5.3.110.0150.04612.66
5.3.100.0100.05812.13
5.3.90.0090.06612.11
5.3.80.0100.06412.10
5.3.70.0090.04912.10
5.3.60.0060.05312.09
5.3.50.0080.04312.04
5.3.40.0160.04612.04
5.3.30.0120.04812.00
5.3.20.0170.05611.78
5.3.10.0050.04811.74
5.3.00.0100.04811.73
5.2.170.0070.0479.23
5.2.160.0090.0489.23
5.2.150.0100.0609.23
5.2.140.0190.0849.23
5.2.130.0080.0829.19
5.2.120.0050.0369.19
5.2.110.0070.0389.20
5.2.100.0070.0309.19
5.2.90.0080.0349.19
5.2.80.0120.0349.19
5.2.70.0080.0569.18
5.2.60.0060.0529.14
5.2.50.0080.0549.11
5.2.40.0090.0359.09
5.2.30.0200.0689.06
5.2.20.0080.0409.05
5.2.10.0050.0488.96
5.2.00.0050.0468.82
5.1.60.0140.0588.10
5.1.50.0150.0568.10
5.1.40.0150.0638.08
5.1.30.0080.0388.43
5.1.20.0070.0558.46
5.1.10.0140.0638.18
5.1.00.0060.0518.18
5.0.50.0050.0286.66
5.0.40.0130.0726.52
5.0.30.0150.1016.34
5.0.20.0100.0516.30
5.0.10.0050.0236.28
5.0.00.0080.0316.27
4.4.90.0040.0214.78
4.4.80.0030.0214.75
4.4.70.0060.0404.75
4.4.60.0120.0324.75
4.4.50.0080.0464.77
4.4.40.0090.0594.71
4.4.30.0060.0354.76
4.4.20.0210.0644.84
4.4.10.0030.0214.85
4.4.00.0040.0514.76
4.3.110.0090.0354.67
4.3.100.0040.0864.66
4.3.90.0060.0314.63
4.3.80.0090.0904.58
4.3.70.0120.0504.63
4.3.60.0070.0334.63
4.3.50.0010.0184.62
4.3.40.0030.0264.54
4.3.30.0020.0173.30
4.3.20.0010.0183.28
4.3.10.0030.0163.23
4.3.00.0000.01710.54

preferences:
43.03 ms | 401 KiB | 5 Q