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->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.0140.00316.63
8.3.50.0110.00622.07
8.3.40.0090.00918.79
8.3.30.0070.00719.12
8.3.20.0000.00720.16
8.3.10.0000.00723.69
8.3.00.0080.00019.50
8.2.180.0090.00918.66
8.2.170.0040.01122.96
8.2.160.0090.00620.44
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0160.00326.16
8.2.120.0040.00422.16
8.2.110.0030.00622.00
8.2.100.0040.00817.97
8.2.90.0060.00319.17
8.2.80.0050.00317.97
8.2.70.0040.00417.63
8.2.60.0050.00317.93
8.2.50.0000.00818.07
8.2.40.0050.00320.07
8.2.30.0060.00318.22
8.2.20.0050.00317.82
8.2.10.0000.00818.06
8.2.00.0000.01017.90
8.1.280.0070.01125.92
8.1.270.0060.00323.96
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0060.00323.96
8.1.230.0110.00019.16
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0040.00417.43
8.1.180.0050.00318.10
8.1.170.0030.00618.33
8.1.160.0040.00422.09
8.1.150.0050.00518.63
8.1.140.0020.00517.53
8.1.130.0070.00017.83
8.1.120.0040.00417.53
8.1.110.0030.00617.54
8.1.100.0040.00417.38
8.1.90.0040.00417.39
8.1.80.0000.00817.36
8.1.70.0040.00417.49
8.1.60.0050.00317.62
8.1.50.0050.00317.41
8.1.40.0000.00817.57
8.1.30.0050.00317.64
8.1.20.0000.00717.60
8.1.10.0080.00017.58
8.1.00.0080.00017.43
8.0.300.0040.00420.69
8.0.290.0000.00817.18
8.0.280.0000.00718.42
8.0.270.0000.00717.30
8.0.260.0030.00317.33
8.0.250.0000.00717.00
8.0.240.0000.00817.10
8.0.230.0000.00716.98
8.0.220.0000.00717.05
8.0.210.0020.00516.88
8.0.200.0060.00017.09
8.0.190.0000.00817.10
8.0.180.0040.00416.98
8.0.170.0000.00817.08
8.0.160.0000.00716.95
8.0.150.0030.00316.86
8.0.140.0030.00516.92
8.0.130.0000.00613.48
8.0.120.0000.00716.95
8.0.110.0040.00416.89
8.0.100.0040.00416.97
8.0.90.0060.00316.79
8.0.80.0060.00916.95
8.0.70.0000.00717.09
8.0.60.0040.00416.88
8.0.50.0000.00716.99
8.0.30.0160.00517.31
8.0.20.0140.00617.40
8.0.10.0040.00416.98
8.0.00.0100.00716.87
7.4.330.0000.00715.00
7.4.320.0030.00316.56
7.4.300.0000.00616.45
7.4.290.0030.00316.60
7.4.280.0030.00316.67
7.4.270.0020.00516.63
7.4.260.0030.00316.54
7.4.250.0040.00416.51
7.4.240.0040.00416.61
7.4.230.0070.00016.66
7.4.220.0090.00916.59
7.4.210.0070.01016.58
7.4.200.0070.00016.33
7.4.190.0000.00716.79
7.4.160.0030.01416.69
7.4.150.0120.00617.40
7.4.140.0080.01017.86
7.4.130.0080.01016.63
7.4.120.0090.00816.56
7.4.110.0110.00716.68
7.4.100.0100.00716.73
7.4.90.0110.00816.65
7.4.80.0120.00919.39
7.4.70.0110.00716.70
7.4.60.0180.00216.63
7.4.50.0080.00016.24
7.4.40.0100.00322.77
7.4.30.0100.00616.59
7.4.00.0030.00714.86
7.3.330.0000.00613.32
7.3.320.0020.00213.48
7.3.310.0040.00416.48
7.3.300.0040.00416.37
7.3.290.0120.00316.43
7.3.280.0080.01016.46
7.3.270.0030.01317.40
7.3.260.0130.01016.59
7.3.250.0100.01116.41
7.3.240.0120.00916.54
7.3.230.0090.00816.45
7.3.210.0100.00716.45
7.3.200.0070.01016.48
7.3.190.0070.01016.38
7.3.180.0000.01616.71
7.3.170.0080.00816.45
7.3.160.0030.01316.45
7.3.120.0090.00615.06
7.2.330.0190.00016.45
7.2.320.0070.01016.81
7.2.310.0150.01116.55
7.2.300.0130.00716.47
7.2.290.0100.00716.77
7.2.60.0110.00016.91
7.2.00.0090.00919.56
7.1.200.0050.00515.87
7.1.100.0030.01018.13
7.1.70.0000.01116.88
7.1.60.0190.00619.46
7.1.50.0110.01434.70
7.1.00.0000.08022.44
7.0.200.0040.00416.80
7.0.140.0000.07722.21
7.0.60.0200.07719.97
7.0.50.0070.05018.00
7.0.40.0030.04720.05
7.0.30.0270.08320.08
7.0.20.0170.04020.21
7.0.10.0070.08320.07
7.0.00.0270.06720.25
5.6.210.0230.07320.50
5.6.200.0100.06318.25
5.6.190.0070.04020.53
5.6.180.0270.06020.49
5.6.170.0300.07320.50
5.6.160.0070.04320.50
5.6.150.0070.07018.30
5.6.140.0100.07718.28
5.6.130.0000.05018.23
5.6.120.0030.04720.98
5.6.110.0030.07321.12
5.6.100.0100.03720.99
5.6.90.0100.06321.00
5.6.80.0030.04320.42
5.6.70.0030.03320.29
5.5.350.0200.05320.43
5.5.340.0100.08318.00
5.5.330.0030.05720.21
5.5.320.0370.04020.21
5.5.310.0370.05720.27
5.5.300.0100.08018.08
5.5.290.0100.07317.94
5.5.280.0070.07020.89
5.5.270.0130.08720.77
5.5.260.0070.08320.88
5.5.250.0030.08720.62
5.5.240.4070.04320.27
5.4.450.0270.05719.67
5.4.440.0670.05719.53
5.4.430.0230.07319.56
5.4.420.0770.06319.36
5.4.410.0630.06019.39
5.4.400.0830.05319.22
5.4.390.1030.07319.15
5.4.380.0400.05318.61
5.4.370.0330.05018.47
5.4.360.0330.04718.59
5.4.350.0230.05718.79
5.4.340.0370.05018.74
5.4.320.0030.03812.52
5.4.310.0090.03712.51
5.4.300.0060.04312.51
5.4.290.0090.04812.49
5.4.280.0090.04712.39
5.4.270.0050.05212.39
5.4.260.0120.05112.39
5.4.250.0140.05412.39
5.4.240.0130.07112.39
5.4.230.0140.05412.38
5.4.220.0110.05312.38
5.4.210.0130.04512.38
5.4.200.0070.05212.39
5.4.190.0090.03512.38
5.4.180.0070.03712.38
5.4.170.0070.03812.38
5.4.160.0080.03712.39
5.4.150.0070.04112.38
5.4.140.0080.03912.06
5.4.130.0080.03612.05
5.4.120.0090.03812.01
5.4.110.0120.04512.01
5.4.100.0140.04212.00
5.4.90.0160.06712.01
5.4.80.0090.05212.00
5.4.70.0120.05512.00
5.4.60.0080.04812.00
5.4.50.0070.05412.00
5.4.40.0160.04511.99
5.4.30.0190.07611.98
5.4.20.0160.06611.98
5.4.10.0210.09611.98
5.4.00.0080.04911.47
5.3.290.0060.04312.80
5.3.280.0080.07712.71
5.3.270.0140.07112.73
5.3.260.0130.04612.72
5.3.250.0200.07712.72
5.3.240.0200.07312.71
5.3.230.0130.05112.71
5.3.220.0100.04812.68
5.3.210.0180.07612.68
5.3.200.0120.06312.68
5.3.190.0190.08412.67
5.3.180.0100.04112.67
5.3.170.0130.05712.67
5.3.160.0110.09112.67
5.3.150.0130.05612.67
5.3.140.0200.07112.66
5.3.130.0030.05412.66
5.3.120.0070.06612.66
5.3.110.0170.05712.66
5.3.100.0270.08312.13
5.3.90.0260.08412.11
5.3.80.0210.05412.10
5.3.70.0150.11212.11
5.3.60.0370.11812.09
5.3.50.0100.05012.04
5.3.40.0090.05012.04
5.3.30.0070.05212.00
5.3.20.0180.07211.78
5.3.10.0070.07911.74
5.3.00.0140.05111.73
5.2.170.0090.0329.23
5.2.160.0040.0359.23
5.2.150.0090.0549.24
5.2.140.0060.0359.23
5.2.130.0060.0339.20
5.2.120.0070.0359.19
5.2.110.0130.0529.20
5.2.100.0070.0399.20
5.2.90.0060.0419.20
5.2.80.0080.0459.19
5.2.70.0070.0439.19
5.2.60.0050.0489.14
5.2.50.0070.0349.11
5.2.40.0060.0409.09
5.2.30.0090.0339.07
5.2.20.0060.0349.05
5.2.10.0290.0898.96
5.2.00.0050.0318.82
5.1.60.0050.0268.11
5.1.50.0120.0568.10
5.1.40.0110.0668.08
5.1.30.0040.0358.44
5.1.20.0080.0418.45
5.1.10.0080.0458.18
5.1.00.0080.0298.18
5.0.50.0060.0236.66
5.0.40.0060.0266.53
5.0.30.0020.0456.33
5.0.20.0140.0386.30
5.0.10.0100.0456.29
5.0.00.0020.0386.27
4.4.90.0030.0284.78
4.4.80.0110.0314.76
4.4.70.0050.0204.75
4.4.60.0070.0454.76
4.4.50.0050.0184.77
4.4.40.0070.0754.70
4.4.30.0090.0364.76
4.4.20.0110.0454.84
4.4.10.0130.0454.85
4.4.00.0070.0304.76
4.3.110.0070.0364.66
4.3.100.0040.0214.66
4.3.90.0040.0204.63
4.3.80.0040.0344.59
4.3.70.0060.0194.63
4.3.60.0030.0214.63
4.3.50.0040.0214.63
4.3.40.0110.0484.54
4.3.30.0100.0353.30
4.3.20.0070.0303.28
4.3.10.0020.0263.23
4.3.00.0230.02710.54

preferences:
50.98 ms | 401 KiB | 5 Q