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('A' , $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.0090.00616.63
8.3.50.0080.01121.98
8.3.40.0070.01018.59
8.3.30.0070.00719.23
8.3.20.0000.00720.14
8.3.10.0080.00023.53
8.3.00.0070.00319.51
8.2.180.0090.01218.30
8.2.170.0130.00322.96
8.2.160.0120.00320.33
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0050.00222.25
8.2.110.0090.00019.21
8.2.100.0030.00917.82
8.2.90.0080.00017.83
8.2.80.0070.00019.32
8.2.70.0000.00817.63
8.2.60.0040.00418.04
8.2.50.0060.00318.10
8.2.40.0040.00420.55
8.2.30.0000.00818.04
8.2.20.0000.00817.95
8.2.10.0040.00718.07
8.2.00.0070.00317.84
8.1.280.0120.00625.92
8.1.270.0060.00323.79
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0070.00423.90
8.1.230.0110.00020.92
8.1.220.0040.00417.74
8.1.210.0000.00818.90
8.1.200.0000.00917.35
8.1.190.0040.00417.36
8.1.180.0050.00318.10
8.1.170.0030.00518.59
8.1.160.0040.00422.15
8.1.150.0030.00618.71
8.1.140.0040.00417.36
8.1.130.0040.00417.84
8.1.120.0000.00717.42
8.1.110.0040.00417.48
8.1.100.0000.00717.37
8.1.90.0080.00017.47
8.1.80.0030.00317.53
8.1.70.0080.00017.37
8.1.60.0030.00617.60
8.1.50.0050.00317.42
8.1.40.0060.00317.43
8.1.30.0000.00817.67
8.1.20.0040.00417.66
8.1.10.0050.00217.48
8.1.00.0050.00317.52
8.0.300.0040.00420.06
8.0.290.0040.00416.75
8.0.280.0040.00418.36
8.0.270.0030.00517.20
8.0.260.0000.00617.36
8.0.250.0030.00317.06
8.0.240.0030.00517.08
8.0.230.0080.00017.03
8.0.220.0040.00417.05
8.0.210.0070.00017.02
8.0.200.0000.00817.12
8.0.190.0030.00517.07
8.0.180.0040.00416.95
8.0.170.0000.00716.91
8.0.160.0040.00416.96
8.0.150.0040.00417.02
8.0.140.0030.00316.94
8.0.130.0000.00613.41
8.0.120.0030.00616.95
8.0.110.0050.00316.88
8.0.100.0090.00017.02
8.0.90.0000.00717.01
8.0.80.0100.00616.94
8.0.70.0000.00917.06
8.0.60.0050.00316.94
8.0.50.0000.00716.90
8.0.30.0130.01017.21
8.0.20.0100.01017.41
8.0.10.0040.00417.06
8.0.00.0120.00716.87
7.4.330.0000.00615.07
7.4.320.0050.00316.65
7.4.300.0030.00316.64
7.4.290.0070.00016.54
7.4.280.0070.00016.61
7.4.270.0070.00016.57
7.4.260.0000.00716.62
7.4.250.0000.00816.62
7.4.240.0020.00516.59
7.4.230.0040.00416.34
7.4.220.0090.01216.65
7.4.210.0070.00916.58
7.4.200.0000.00716.53
7.4.190.0050.00316.68
7.4.160.0130.00316.49
7.4.150.0220.00617.40
7.4.140.0090.00917.86
7.4.130.0090.00816.55
7.4.120.0110.00716.61
7.4.110.0130.00916.61
7.4.100.0150.00316.56
7.4.90.0100.00716.59
7.4.80.0090.01219.39
7.4.70.0040.01316.77
7.4.60.0030.01316.56
7.4.50.0000.00816.64
7.4.40.0090.00622.77
7.4.30.0090.01316.54
7.4.00.0020.01414.82
7.3.330.0070.00013.47
7.3.320.0060.00013.41
7.3.310.0030.00316.58
7.3.300.0050.00516.44
7.3.290.0140.00816.49
7.3.280.0090.00916.40
7.3.270.0120.00617.40
7.3.260.0100.01416.44
7.3.250.0080.01016.52
7.3.240.0070.01016.54
7.3.230.0090.01216.44
7.3.210.0030.01316.42
7.3.200.0130.01019.39
7.3.190.0090.01216.64
7.3.180.0030.01316.56
7.3.170.0130.00316.63
7.3.160.0060.01116.43
7.3.120.0070.01014.96
7.3.110.0090.01014.85
7.3.100.0060.00614.90
7.3.90.0110.00514.85
7.3.80.0010.01014.78
7.3.70.0080.00814.81
7.3.60.0090.00514.95
7.3.50.0020.01214.97
7.3.40.0020.01114.74
7.3.30.0050.00914.79
7.3.20.0070.00716.47
7.3.10.0030.01116.68
7.3.00.0080.00916.72
7.2.330.0130.00416.69
7.2.320.0120.00416.83
7.2.310.0030.01416.39
7.2.300.0070.01016.85
7.2.290.0130.00316.80
7.2.250.0070.01215.14
7.2.240.0030.01415.04
7.2.230.0090.00514.90
7.2.220.0030.01315.11
7.2.210.0080.00815.02
7.2.200.0060.00915.12
7.2.190.0030.00915.02
7.2.180.0030.01015.15
7.2.170.0040.00915.05
7.2.60.0130.00416.33
7.2.00.0060.00619.52
7.1.330.0090.00515.70
7.1.320.0050.00715.86
7.1.310.0050.00815.70
7.1.300.0050.01015.67
7.1.290.0070.00615.70
7.1.280.0040.00915.86
7.1.270.0020.01115.74
7.1.260.0050.00715.91
7.1.200.0060.00615.99
7.1.100.0030.00918.03
7.1.70.0080.00017.12
7.1.60.0040.01919.46
7.1.50.0070.00316.66
7.1.00.0030.07322.54
7.0.200.0190.00414.93
7.0.140.0070.07322.12
7.0.60.0100.07320.04
7.0.50.0000.06717.74
7.0.40.0130.08020.07
7.0.30.0270.06020.25
7.0.20.0070.05020.12
7.0.10.0030.04720.15
7.0.00.0000.05020.06
5.6.280.0030.07321.00
5.6.210.0000.04320.68
5.6.200.0130.06018.13
5.6.190.0100.08020.46
5.6.180.0330.06320.78
5.6.170.0330.07020.48
5.6.160.0070.04020.55
5.6.150.0100.06718.27
5.6.140.0070.08718.15
5.6.130.0070.05318.17
5.6.120.0070.04321.17
5.6.110.0100.08321.00
5.6.100.0070.08321.01
5.6.90.0030.07020.96
5.6.80.0100.08020.52
5.6.70.4570.04020.52
5.5.350.0270.07320.33
5.5.340.0030.03717.95
5.5.330.0170.06020.27
5.5.320.0300.06720.27
5.5.310.0270.04320.38
5.5.300.0170.05017.99
5.5.290.0070.04018.02
5.5.280.0070.08020.67
5.5.270.0100.08020.77
5.5.260.0000.04320.77
5.5.250.0100.08320.48
5.5.240.4370.04320.30
5.4.450.0730.05719.58
5.4.440.0600.06019.53
5.4.430.0570.05719.29
5.4.420.0700.06319.57
5.4.410.0600.05319.30
5.4.400.0000.07019.22
5.4.390.0730.06319.01
5.4.380.0370.04718.79
5.4.370.0300.05318.57
5.4.360.0300.05018.48
5.4.350.0300.05718.75
5.4.340.0300.05318.77
5.4.320.0060.03612.52
5.4.310.0050.03912.51
5.4.300.0080.04212.52
5.4.290.0060.03812.50
5.4.280.0090.03212.39
5.4.270.0070.03612.39
5.4.260.0050.04012.39
5.4.250.0050.03912.39
5.4.240.0080.03412.39
5.4.230.0070.03812.39
5.4.220.0060.03912.39
5.4.210.0080.03312.38
5.4.200.0060.03812.39
5.4.190.0080.03512.38
5.4.180.0070.03812.38
5.4.170.0070.04012.39
5.4.160.0050.03812.39
5.4.150.0060.03812.39
5.4.140.0030.04112.07
5.4.130.0080.03512.05
5.4.120.0020.04212.02
5.4.110.0040.03912.01
5.4.100.0080.03612.01
5.4.90.0060.03912.01
5.4.80.0050.04312.01
5.4.70.0100.03312.00
5.4.60.0050.03912.00
5.4.50.0080.04312.00
5.4.40.0080.03511.99
5.4.30.0040.03911.99
5.4.20.0050.03911.98
5.4.10.0070.03811.98
5.4.00.0040.03911.48
5.3.290.0050.04012.80
5.3.280.0070.04012.71
5.3.270.0060.03912.72
5.3.260.0060.04412.72
5.3.250.0070.03612.72
5.3.240.0070.04012.72
5.3.230.0060.04212.71
5.3.220.0070.03612.68
5.3.210.0040.04212.68
5.3.200.0060.03812.68
5.3.190.0070.03912.68
5.3.180.0060.03612.68
5.3.170.0070.03812.67
5.3.160.0060.03712.67
5.3.150.0070.03712.68
5.3.140.0070.04012.66
5.3.130.0080.04412.66
5.3.120.0080.03912.66
5.3.110.0090.05012.66
5.3.100.0070.04312.13
5.3.90.0060.04012.11
5.3.80.0050.04012.10
5.3.70.0090.03812.11
5.3.60.0060.04112.09
5.3.50.0080.03812.04
5.3.40.0050.04112.04
5.3.30.0050.04012.00
5.3.20.0050.03711.78
5.3.10.0040.03711.74
5.3.00.0060.03811.73
5.2.170.0060.0309.23
5.2.160.0020.0329.24
5.2.150.0040.0329.23
5.2.140.0050.0309.23
5.2.130.0050.0299.20
5.2.120.0020.0329.19
5.2.110.0050.0299.20
5.2.100.0030.0309.20
5.2.90.0040.0309.20
5.2.80.0020.0339.19
5.2.70.0030.0319.19
5.2.60.0060.0289.14
5.2.50.0020.0329.11
5.2.40.0040.0339.09
5.2.30.0040.0299.06
5.2.20.0030.0309.05
5.2.10.0050.0268.95
5.2.00.0060.0288.82
5.1.60.0030.0248.11
5.1.50.0030.0258.11
5.1.40.0030.0258.08
5.1.30.0040.0268.43
5.1.20.0020.0288.46
5.1.10.0030.0288.18
5.1.00.0030.0288.18
5.0.50.0050.0276.66
5.0.40.0020.0206.52
5.0.30.0020.0336.33
5.0.20.0020.0286.30
5.0.10.0030.0276.28
5.0.00.0070.0336.27
4.4.90.0030.0194.78
4.4.80.0020.0214.75
4.4.70.0040.0154.76
4.4.60.0020.0174.76
4.4.50.0070.0324.77
4.4.40.0050.0344.71
4.4.30.0040.0214.76
4.4.20.0030.0244.84
4.4.10.0040.0224.85
4.4.00.0040.0324.76
4.3.110.0020.0184.67
4.3.100.0020.0174.67
4.3.90.0030.0214.63
4.3.80.0040.0244.58
4.3.70.0020.0154.63
4.3.60.0030.0164.63
4.3.50.0070.0174.63
4.3.40.0050.0294.54
4.3.30.0040.0173.30
4.3.20.0050.0193.28
4.3.10.0030.0273.23
4.3.00.0300.01310.54

preferences:
51.62 ms | 401 KiB | 5 Q