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[$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.00716.63
8.3.50.0120.00621.93
8.3.40.0100.00718.91
8.3.30.0110.00418.82
8.3.20.0080.00020.22
8.3.10.0040.00423.66
8.3.00.0060.00319.38
8.2.180.0090.00918.53
8.2.170.0070.00722.96
8.2.160.0030.01020.46
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0110.00726.16
8.2.120.0040.00422.08
8.2.110.0090.00022.08
8.2.100.0110.00017.91
8.2.90.0000.00819.17
8.2.80.0030.00517.97
8.2.70.0050.00317.75
8.2.60.0050.00218.16
8.2.50.0080.00018.07
8.2.40.0000.00820.01
8.2.30.0050.00318.08
8.2.20.0070.00017.86
8.2.10.0030.00618.06
8.2.00.0000.00817.72
8.1.280.0090.00925.92
8.1.270.0080.00023.97
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.87
8.1.230.0030.00719.14
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00717.38
8.1.190.0030.00517.41
8.1.180.0000.00818.10
8.1.170.0060.00318.61
8.1.160.0040.00422.05
8.1.150.0040.00718.62
8.1.140.0050.00217.48
8.1.130.0030.00317.86
8.1.120.0070.00017.46
8.1.110.0080.00017.49
8.1.100.0000.00717.48
8.1.90.0040.00417.48
8.1.80.0000.00717.40
8.1.70.0000.00717.38
8.1.60.0100.00017.55
8.1.50.0050.00317.53
8.1.40.0030.00617.52
8.1.30.0000.00817.58
8.1.20.0000.00717.66
8.1.10.0040.00417.46
8.1.00.0040.00417.55
8.0.300.0000.00720.79
8.0.290.0060.00317.30
8.0.280.0050.00218.50
8.0.270.0000.00717.29
8.0.260.0030.00317.30
8.0.250.0070.00016.93
8.0.240.0040.00417.08
8.0.230.0000.00717.10
8.0.220.0000.00717.00
8.0.210.0070.00016.92
8.0.200.0070.00017.10
8.0.190.0040.00416.93
8.0.180.0000.00716.94
8.0.170.0040.00417.04
8.0.160.0040.00417.03
8.0.150.0030.00516.88
8.0.140.0000.00816.79
8.0.130.0000.00613.46
8.0.120.0040.00416.86
8.0.110.0030.00516.98
8.0.100.0050.00217.05
8.0.90.0040.00416.95
8.0.80.0030.01216.93
8.0.70.0070.00016.92
8.0.60.0000.00816.82
8.0.50.0070.00016.84
8.0.30.0110.00817.06
8.0.20.0110.00717.40
8.0.10.0050.00317.07
8.0.00.0090.00916.93
7.4.330.0030.00415.00
7.4.320.0030.00316.69
7.4.300.0030.00316.49
7.4.290.0050.00316.63
7.4.280.0000.00716.52
7.4.270.0000.00716.57
7.4.260.0000.00716.60
7.4.250.0000.00916.49
7.4.240.0050.00216.60
7.4.230.0040.00416.54
7.4.220.0060.01116.58
7.4.210.0080.00916.61
7.4.200.0040.00416.67
7.4.190.0050.00216.60
7.4.160.0120.00916.59
7.4.150.0140.00317.40
7.4.140.0140.00817.86
7.4.130.0080.00816.64
7.4.120.0100.00816.65
7.4.110.0100.01416.64
7.4.100.0070.01016.64
7.4.90.0100.00716.36
7.4.80.0150.00619.39
7.4.70.0100.00716.52
7.4.60.0120.01216.62
7.4.50.0050.00316.48
7.4.40.0090.00722.77
7.4.30.0070.01016.37
7.4.00.0000.01415.11
7.3.330.0020.00413.54
7.3.320.0030.00313.39
7.3.310.0030.00316.32
7.3.300.0050.00316.48
7.3.290.0060.01516.47
7.3.280.0080.01016.48
7.3.270.0040.01317.40
7.3.260.0070.01016.64
7.3.250.0110.00616.57
7.3.240.0130.00316.66
7.3.230.0130.00316.56
7.3.210.0130.00516.44
7.3.200.0090.01219.39
7.3.190.0030.02016.46
7.3.180.0060.00916.32
7.3.170.0060.01016.56
7.3.160.0180.00316.50
7.3.120.0040.01414.94
7.3.110.0110.00715.15
7.3.100.0080.00415.15
7.3.90.0030.00814.91
7.3.80.0070.01014.86
7.3.70.0060.00614.86
7.3.60.0040.01214.76
7.3.50.0070.00714.64
7.3.40.0030.00714.75
7.3.30.0040.00714.73
7.3.20.0080.00416.77
7.3.10.0030.01316.76
7.3.00.0040.01216.50
7.2.330.0090.00916.44
7.2.320.0040.01516.71
7.2.310.0060.01016.75
7.2.300.0130.00616.66
7.2.290.0120.00916.86
7.2.250.0130.00715.30
7.2.240.0100.00715.26
7.2.230.0040.01115.09
7.2.220.0070.00715.02
7.2.210.0070.01015.08
7.2.200.0090.00315.15
7.2.190.0030.00915.15
7.2.180.0040.01114.77
7.2.170.0000.01715.06
7.2.160.0070.00714.94
7.2.150.0080.00317.05
7.2.140.0000.01216.70
7.2.130.0090.00616.99
7.2.120.0040.01116.72
7.2.110.0090.00017.13
7.2.100.0030.00716.69
7.2.90.0060.00917.10
7.2.80.0090.00616.85
7.2.70.0030.01316.81
7.2.60.0070.01016.79
7.2.50.0070.00716.95
7.2.40.0080.00317.06
7.2.30.0000.01117.01
7.2.20.0030.00616.82
7.2.10.0100.00317.05
7.2.00.0060.00818.17
7.1.330.0060.00615.90
7.1.320.0040.00815.61
7.1.310.0060.00915.94
7.1.300.0090.00315.46
7.1.290.0040.00715.64
7.1.280.0060.00615.74
7.1.270.0000.00915.88
7.1.260.0100.00316.02
7.1.250.0090.00915.90
7.1.200.0030.00915.84
7.1.100.0090.00318.18
7.1.70.0070.00317.13
7.1.60.0100.01319.46
7.1.50.0070.01417.07
7.1.00.0030.07322.51
7.0.200.0000.00716.80
7.0.140.0070.07322.09
7.0.60.0070.07019.84
7.0.50.0070.07017.96
7.0.40.0000.05020.06
7.0.30.0270.04720.25
7.0.20.0270.04320.09
7.0.10.0130.05020.26
7.0.00.0070.04320.16
5.6.280.0030.07320.79
5.6.210.0070.04320.70
5.6.200.0170.08018.18
5.6.190.0070.05720.61
5.6.180.0100.05320.67
5.6.170.0330.07020.47
5.6.160.0070.04320.50
5.6.150.0070.08018.14
5.6.140.0070.07718.18
5.6.130.0130.07318.21
5.6.120.0100.08321.00
5.6.110.0200.05721.00
5.6.100.0100.09021.13
5.6.90.0100.07020.96
5.6.80.0130.05320.36
5.5.350.0170.03020.34
5.5.340.0070.04717.95
5.5.330.0070.05720.36
5.5.320.0370.04320.31
5.5.310.0330.05720.38
5.5.300.0100.07317.94
5.5.290.0130.04017.96
5.5.280.0170.07320.90
5.5.270.0100.04020.87
5.5.260.0130.05320.74
5.5.250.0070.07020.70
5.5.240.3870.05020.13
5.4.450.0600.07319.47
5.4.440.0600.06019.47
5.4.430.1000.04719.18
5.4.420.0170.05019.36
5.4.410.0100.06019.35
5.4.400.0770.05319.34
5.4.390.0330.07319.04
5.4.380.0200.07018.63
5.4.370.0430.05018.75
5.4.360.0270.07018.79
5.4.350.0300.06318.59
5.4.340.0330.05018.84
5.4.320.0080.03512.51
5.4.310.0070.04312.51
5.4.300.0060.03812.52
5.4.290.0080.05112.50
5.4.280.0220.12712.40
5.4.270.0060.05312.39
5.4.260.0070.05512.40
5.4.250.0060.05512.39
5.4.240.0090.05712.40
5.4.230.0090.05812.39
5.4.220.0090.05612.39
5.4.210.0100.05512.39
5.4.200.0070.05512.38
5.4.190.0120.05112.38
5.4.180.0110.04912.39
5.4.170.0140.07512.39
5.4.160.0080.04812.39
5.4.150.0130.04312.38
5.4.140.0080.07812.06
5.4.130.0120.05712.06
5.4.120.0140.08312.02
5.4.110.0080.05812.01
5.4.100.0120.05112.01
5.4.90.0090.05812.01
5.4.80.0080.05312.01
5.4.70.0100.05312.00
5.4.60.0120.07512.00
5.4.50.0120.05412.00
5.4.40.0160.05511.98
5.4.30.0230.07311.99
5.4.20.0110.05011.99
5.4.10.0050.05111.98
5.4.00.0080.05411.47
5.3.290.0100.04712.80
5.3.280.0140.05512.71
5.3.270.0080.05112.73
5.3.260.0070.06112.72
5.3.250.0110.06512.72
5.3.240.0100.05412.72
5.3.230.0050.06412.71
5.3.220.0080.05512.68
5.3.210.0070.05812.68
5.3.200.0070.05712.68
5.3.190.0100.05112.68
5.3.180.0080.06712.67
5.3.170.0130.05312.67
5.3.160.0090.04912.67
5.3.150.0060.04712.67
5.3.140.0130.05312.66
5.3.130.0100.06912.66
5.3.120.0090.06112.66
5.3.110.0150.06412.65
5.3.100.0090.05512.13
5.3.90.0140.05012.11
5.3.80.0070.07312.11
5.3.70.0070.04212.10
5.3.60.0100.03712.09
5.3.50.0100.04712.04
5.3.40.0070.05812.04
5.3.30.0090.06012.00
5.3.20.0100.05011.78
5.3.10.0080.04311.74
5.3.00.0050.05711.73
5.2.170.0060.0439.24
5.2.160.0060.0349.24
5.2.150.0060.0459.23
5.2.140.0060.0469.23
5.2.130.0050.0439.19
5.2.120.0030.0539.20
5.2.110.0080.0419.20
5.2.100.0050.0459.19
5.2.90.0070.0319.19
5.2.80.0070.0339.19
5.2.70.0050.0339.18
5.2.60.0100.0429.14
5.2.50.0130.0859.11
5.2.40.0090.0389.09
5.2.30.0080.0429.07
5.2.20.0060.0329.05
5.2.10.0080.0328.96
5.2.00.0030.0358.82
5.1.60.0060.0258.11
5.1.50.0080.0318.10
5.1.40.0050.0308.08
5.1.30.0060.0278.43
5.1.20.0030.0328.45
5.1.10.0040.0298.18
5.1.00.0080.0258.18
5.0.50.0030.0286.66
5.0.40.0020.0286.52
5.0.30.0070.0516.34
5.0.20.0020.0226.30
5.0.10.0070.0216.28
5.0.00.0080.0706.27
4.4.90.0030.0174.77
4.4.80.0030.0174.75
4.4.70.0050.0154.76
4.4.60.0010.0184.75
4.4.50.0080.0134.77
4.4.40.0060.0254.71
4.4.30.0070.0154.76
4.4.20.0030.0194.84
4.4.10.0070.0234.85
4.4.00.0070.0244.76
4.3.110.0050.0154.67
4.3.100.0080.0424.66
4.3.90.0030.0184.64
4.3.80.0030.0324.59
4.3.70.0060.0154.63
4.3.60.0050.0134.63
4.3.50.0040.0164.63
4.3.40.0040.0264.53
4.3.30.0020.0223.30
4.3.20.0040.0183.28
4.3.10.0070.0183.24
4.3.00.0200.02310.54

preferences:
57.29 ms | 400 KiB | 5 Q