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 = $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.0060.00918.55
8.3.50.0140.00722.12
8.3.40.0140.01418.81
8.3.30.0030.01019.22
8.3.20.0040.00420.38
8.3.10.0030.00523.56
8.3.00.0050.00319.51
8.2.180.0070.00718.23
8.2.170.0090.00622.96
8.2.160.0060.00920.57
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0100.00326.16
8.2.120.0040.00422.20
8.2.110.0040.01822.16
8.2.100.0080.00417.84
8.2.90.0000.00819.34
8.2.80.0080.00017.97
8.2.70.0000.00817.75
8.2.60.0000.00918.04
8.2.50.0050.00318.07
8.2.40.0030.00620.07
8.2.30.0000.00718.15
8.2.20.0000.00717.84
8.2.10.0040.00418.03
8.2.00.0040.00717.84
8.1.280.0160.00325.92
8.1.270.0080.00022.11
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0090.00023.96
8.1.230.0000.01119.21
8.1.220.0040.00417.76
8.1.210.0040.00418.77
8.1.200.0000.00917.35
8.1.190.0000.00817.40
8.1.180.0030.00619.01
8.1.170.0060.00318.59
8.1.160.0000.00722.06
8.1.150.0030.00618.67
8.1.140.0040.00417.53
8.1.130.0070.00017.76
8.1.120.0040.00417.40
8.1.110.0000.01017.49
8.1.100.0030.00617.44
8.1.90.0040.00417.50
8.1.80.0030.00517.48
8.1.70.0030.00517.44
8.1.60.0000.00917.50
8.1.50.0040.00417.49
8.1.40.0050.00217.48
8.1.30.0030.00517.67
8.1.20.0000.00917.65
8.1.10.0050.00217.57
8.1.00.0030.00617.62
8.0.300.0000.00820.79
8.0.290.0040.00417.18
8.0.280.0030.00318.46
8.0.270.0000.00716.79
8.0.260.0000.00717.32
8.0.250.0030.00616.96
8.0.240.0000.00817.03
8.0.230.0000.00817.05
8.0.220.0040.00416.99
8.0.210.0050.00316.88
8.0.200.0000.00617.08
8.0.190.0000.00816.95
8.0.180.0050.00316.98
8.0.170.0020.00516.92
8.0.160.0040.00416.96
8.0.150.0030.00517.04
8.0.140.0070.00016.91
8.0.130.0000.00613.41
8.0.120.0000.00816.95
8.0.110.0070.00016.88
8.0.100.0040.00317.10
8.0.90.0070.00016.99
8.0.80.0120.00316.95
8.0.70.0050.00216.87
8.0.60.0020.00517.03
8.0.50.0040.00416.90
8.0.30.0120.00717.12
8.0.20.0090.01117.40
8.0.10.0040.00417.10
8.0.00.0060.01416.88
7.4.330.0060.00015.00
7.4.320.0040.00416.43
7.4.300.0000.00616.48
7.4.290.0040.00416.52
7.4.280.0070.00016.43
7.4.270.0040.00416.59
7.4.260.0030.00316.64
7.4.250.0050.00216.57
7.4.240.0060.00116.53
7.4.230.0030.00316.52
7.4.220.0150.00616.60
7.4.210.0090.00816.67
7.4.200.0040.00416.46
7.4.190.0030.00316.49
7.4.160.0120.00316.67
7.4.150.0090.00917.40
7.4.140.0100.00817.86
7.4.130.0110.00616.52
7.4.120.0090.00916.52
7.4.110.0060.01216.73
7.4.100.0160.00316.59
7.4.90.0030.01516.60
7.4.80.0140.00519.39
7.4.70.0060.01016.39
7.4.60.0090.00916.56
7.4.50.0000.00516.39
7.4.40.0030.01222.77
7.4.30.0100.00716.36
7.4.00.0110.00315.00
7.3.330.0060.00013.39
7.3.320.0030.00313.44
7.3.310.0000.00716.37
7.3.300.0060.00316.34
7.3.290.0080.01216.52
7.3.280.0100.00716.46
7.3.270.0140.00317.40
7.3.260.0100.00716.54
7.3.250.0110.00916.55
7.3.240.0100.01016.41
7.3.230.0170.00016.68
7.3.210.0100.00716.67
7.3.200.0110.01119.39
7.3.190.0180.00416.48
7.3.180.0110.00416.47
7.3.170.0130.00316.68
7.3.160.0070.01016.64
7.3.120.0070.00714.86
7.3.10.0120.00516.42
7.3.00.0170.00316.43
7.2.330.0030.01516.81
7.2.320.0120.00616.85
7.2.310.0030.01616.73
7.2.300.0100.00716.84
7.2.290.0110.00716.43
7.2.130.0080.00816.71
7.2.120.0000.01316.89
7.2.110.0110.01416.77
7.2.100.0180.00316.85
7.2.90.0180.00416.80
7.2.80.0130.00916.62
7.2.70.0050.01316.69
7.2.60.0170.00516.79
7.2.50.0080.00516.93
7.2.40.0100.00316.68
7.2.30.0110.00416.74
7.2.20.0090.00617.00
7.2.10.0030.00916.66
7.2.00.0050.00718.19
7.1.250.0050.01215.44
7.1.200.0070.00715.78
7.1.100.0090.00618.27
7.1.70.0250.00017.34
7.1.60.0110.01419.46
7.1.50.0240.00934.75
7.1.00.0000.07722.28
7.0.200.0030.01316.76
7.0.140.0030.07322.08
7.0.60.0030.05020.07
7.0.50.0070.05717.89
7.0.40.0070.04020.31
7.0.30.0230.04320.25
7.0.20.0230.04020.19
7.0.10.0130.08320.39
7.0.00.0000.08020.10
5.6.280.0100.06720.93
5.6.210.0070.07020.57
5.6.200.0130.07718.18
5.6.190.0100.08020.63
5.6.180.0330.07720.48
5.6.170.0330.07320.54
5.6.160.0070.06720.52
5.6.150.0130.04318.29
5.6.140.0030.06718.25
5.6.130.0000.04718.16
5.6.120.0070.08021.16
5.6.110.0070.07721.13
5.6.100.0100.03721.08
5.6.90.0030.07021.00
5.6.80.0030.04720.29
5.5.350.4300.04020.42
5.5.340.0100.05018.02
5.5.330.0070.08320.27
5.5.320.0270.03720.32
5.5.310.0330.05720.34
5.5.300.0100.08018.02
5.5.290.0130.06317.95
5.5.280.0070.03720.89
5.5.270.0130.07720.80
5.5.260.0100.03720.98
5.5.250.0130.05020.46
5.5.240.0070.08720.27
5.4.450.3200.04319.55
5.4.440.3130.04719.54
5.4.430.2970.04019.48
5.4.420.3100.03719.34
5.4.410.3170.04019.07
5.4.400.3070.03719.15
5.4.390.3200.03719.19
5.4.380.3070.03719.07
5.4.370.3700.03718.98
5.4.360.3470.04019.31
5.4.350.3870.03319.18
5.4.340.3270.04019.06
5.4.320.3070.02719.20
5.4.310.3000.03019.14
5.4.300.3300.04318.94
5.4.290.3230.04019.14
5.4.280.3230.04018.95
5.4.270.3300.03318.95
5.4.260.3170.03319.06
5.4.250.3230.04319.22
5.4.240.3230.04018.98
5.4.230.3500.04319.09
5.4.220.3130.04719.13
5.4.210.3230.04019.14
5.4.200.3270.04019.19
5.4.190.3130.03319.21
5.4.180.3030.04019.07
5.4.170.2900.04319.07
5.4.160.3300.03318.97
5.4.150.3000.03718.93
5.4.140.3130.04316.55
5.4.130.3070.03316.54
5.4.120.3500.03716.38
5.4.110.3170.04316.50
5.4.100.3200.03716.42
5.4.90.3230.03316.50
5.4.80.3230.03316.23
5.4.70.3130.03716.57
5.4.60.3230.04016.55
5.4.50.3200.03016.54
5.4.40.2970.03316.42
5.4.30.3000.03316.53
5.4.20.3230.03316.53
5.4.10.3230.03716.50
5.4.00.2930.03715.77
5.3.290.2970.03714.68
5.3.280.3230.04014.52
5.3.270.3830.04314.62
5.3.260.3270.04314.69
5.3.250.3230.03714.63
5.3.240.3170.04014.61
5.3.230.3500.04314.52
5.3.220.3630.03714.57
5.3.210.3330.03314.48
5.3.200.3130.03714.58
5.3.190.3230.03014.57
5.3.180.3300.03714.59
5.3.170.3170.03714.54
5.3.160.3430.03314.47
5.3.150.3270.03714.62
5.3.140.3370.04314.63
5.3.130.3230.03714.57
5.3.120.3200.04014.47
5.3.110.4070.02314.70
5.3.100.3200.03714.19
5.3.90.3170.04013.95
5.3.80.3200.03714.10
5.3.70.3270.03714.00
5.3.60.2930.04314.06
5.3.50.2830.03714.18
5.3.40.3000.03713.94
5.3.30.3130.04013.84
5.3.20.3200.03713.71
5.3.10.3230.03713.89
5.3.00.3230.03313.57
5.2.170.2670.02011.39
5.2.160.2600.03011.28
5.2.150.2470.03311.13
5.2.140.2600.02311.13
5.2.130.2430.03011.13
5.2.120.2700.03011.13
5.2.110.2700.03011.13
5.2.100.2730.03011.13
5.2.90.2630.03011.13
5.2.80.2530.02711.23
5.2.70.2730.02311.13
5.2.60.2570.02011.13
5.2.50.2970.03011.13
5.2.40.2270.02311.13
5.2.30.2070.02311.13
5.2.20.2330.02311.13
5.2.10.1970.03011.13
5.2.00.2330.03011.13
5.1.60.2300.02311.13
5.1.50.2000.02011.13
5.1.40.2270.02711.13
5.1.30.1970.02711.13
5.1.20.2300.02011.13
5.1.10.2300.02711.13
5.1.00.2270.03011.13
5.0.50.1300.02311.13
5.0.40.0870.02311.13
5.0.30.1070.04011.13
5.0.20.1370.01711.13
5.0.10.1230.02311.13
5.0.00.1270.02711.13
4.4.90.1130.01711.13
4.4.80.0530.01011.13
4.4.70.1170.02311.13
4.4.60.1030.01311.13
4.4.50.1200.02011.13
4.4.40.1200.03011.13
4.4.30.1170.01711.13
4.4.20.0500.01711.13
4.4.10.0530.01711.13
4.4.00.1030.02311.13
4.3.110.1070.02011.13
4.3.100.1000.01311.13
4.3.90.0970.01711.13
4.3.80.0730.02711.13
4.3.70.0530.01311.13
4.3.60.1000.01311.13
4.3.50.0730.01711.13
4.3.40.1170.03011.13
4.3.30.0570.02011.13
4.3.20.0500.01711.13
4.3.10.0470.01711.13
4.3.00.0030.01011.13

preferences:
43.55 ms | 401 KiB | 5 Q