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->callback = 'callback'; //$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.0000.01416.61
8.3.50.0120.00721.96
8.3.40.0120.00318.79
8.3.30.0040.01119.17
8.3.20.0000.00720.33
8.3.10.0040.00423.48
8.3.00.0070.00319.38
8.2.180.0000.02118.25
8.2.170.0110.00422.96
8.2.160.0030.01020.52
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0070.00022.21
8.2.110.0050.00322.20
8.2.100.0080.00417.91
8.2.90.0040.00419.39
8.2.80.0000.00817.97
8.2.70.0000.00817.75
8.2.60.0050.00318.05
8.2.50.0030.00518.07
8.2.40.0000.00819.67
8.2.30.0000.00818.23
8.2.20.0000.00717.96
8.2.10.0040.00418.07
8.2.00.0080.00017.91
8.1.280.0090.00625.92
8.1.270.0080.00023.88
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00723.80
8.1.230.0090.00319.22
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0060.00317.25
8.1.190.0040.00417.51
8.1.180.0090.00018.10
8.1.170.0050.00318.51
8.1.160.0000.00722.06
8.1.150.0090.00018.60
8.1.140.0070.00017.37
8.1.130.0070.00017.83
8.1.120.0050.00317.52
8.1.110.0000.00817.39
8.1.100.0000.00717.48
8.1.90.0000.00717.47
8.1.80.0000.00717.47
8.1.70.0040.00417.51
8.1.60.0040.00417.54
8.1.50.0000.00817.61
8.1.40.0040.00417.54
8.1.30.0080.00017.68
8.1.20.0080.00017.63
8.1.10.0000.01017.65
8.1.00.0030.00517.57
8.0.300.0000.00720.41
8.0.290.0040.00417.29
8.0.280.0000.00718.54
8.0.270.0050.00317.32
8.0.260.0030.00318.50
8.0.250.0000.00717.03
8.0.240.0040.00417.03
8.0.230.0040.00417.11
8.0.220.0000.00717.02
8.0.210.0030.00316.98
8.0.200.0000.00716.91
8.0.190.0080.00016.95
8.0.180.0070.00017.10
8.0.170.0000.00716.93
8.0.160.0000.00817.04
8.0.150.0030.00416.94
8.0.140.0030.00516.95
8.0.130.0070.00013.47
8.0.120.0050.00316.98
8.0.110.0030.00617.01
8.0.100.0050.00216.86
8.0.90.0070.00017.12
8.0.80.0130.00316.99
8.0.70.0000.00717.02
8.0.60.0040.00416.96
8.0.50.0040.00417.02
8.0.30.0110.00817.12
8.0.20.0140.00917.40
8.0.10.0040.00416.96
8.0.00.0130.00716.86
7.4.330.0030.00315.09
7.4.320.0030.00316.70
7.4.300.0000.00716.65
7.4.290.0040.00416.50
7.4.280.0000.00716.63
7.4.270.0000.00816.63
7.4.260.0030.00316.67
7.4.250.0030.00616.54
7.4.240.0040.00416.53
7.4.230.0030.00316.47
7.4.220.0140.01016.41
7.4.210.0040.01416.71
7.4.200.0000.00716.46
7.4.190.0040.00416.82
7.4.160.0110.00716.57
7.4.150.0060.01617.40
7.4.140.0070.01117.86
7.4.130.0050.01116.74
7.4.120.0110.00716.66
7.4.110.0090.00916.66
7.4.100.0120.00916.60
7.4.90.0090.00916.52
7.4.80.0070.01019.39
7.4.70.0030.01416.67
7.4.60.0030.01716.54
7.4.50.0000.00416.39
7.4.40.0070.01122.77
7.4.30.0100.00616.56
7.4.10.0090.01015.20
7.4.00.0090.00815.05
7.3.330.0030.00313.32
7.3.320.0030.00313.23
7.3.310.0040.00416.43
7.3.300.0000.00916.46
7.3.290.0060.01116.41
7.3.280.0110.00816.46
7.3.270.0090.00917.40
7.3.260.0100.01116.41
7.3.250.0090.00816.57
7.3.240.0090.00616.64
7.3.230.0070.01416.48
7.3.210.0030.01316.71
7.3.200.0070.01819.39
7.3.190.0100.00716.43
7.3.180.0120.00316.52
7.3.170.0120.00416.50
7.3.160.0110.00716.49
7.3.130.0080.01114.64
7.3.120.0040.01415.00
7.3.110.0050.01114.74
7.3.100.0080.00614.65
7.3.90.0090.00714.90
7.3.80.0060.00614.80
7.3.70.0100.00714.85
7.3.60.0030.00914.97
7.3.50.0030.01014.89
7.3.40.0070.00314.85
7.3.30.0020.01414.93
7.3.20.0040.00916.58
7.3.10.0050.00916.75
7.3.00.0070.00716.72
7.2.330.0060.01316.57
7.2.320.0030.01616.80
7.2.310.0100.00716.84
7.2.300.0090.00816.80
7.2.290.0080.00816.43
7.2.260.0070.01014.91
7.2.250.0110.00715.09
7.2.240.0160.00314.94
7.2.230.0020.01215.10
7.2.220.0050.01215.08
7.2.210.0110.00515.23
7.2.200.0040.01115.14
7.2.190.0080.00915.03
7.2.180.0060.00615.08
7.2.170.0090.00715.20
7.2.160.0000.01415.14
7.2.150.0070.01117.10
7.2.140.0110.00716.96
7.2.130.0080.00316.90
7.2.120.0030.00617.09
7.2.110.0100.00717.01
7.2.100.0000.01416.93
7.2.90.0080.00416.66
7.2.80.0030.00916.96
7.2.70.0040.01117.01
7.2.60.0040.00816.70
7.2.50.0060.00916.97
7.2.40.0030.01316.81
7.2.30.0030.01216.86
7.2.20.0100.00017.14
7.2.10.0040.01516.99
7.2.00.0030.01018.25
7.1.330.0020.01115.69
7.1.320.0100.00615.78
7.1.310.0030.00915.92
7.1.300.0080.00315.85
7.1.290.0030.01015.88
7.1.280.0080.00515.71
7.1.270.0040.01015.71
7.1.260.0030.01215.93
7.1.250.0100.00315.64
7.1.240.0100.00315.54
7.1.230.0060.00615.77
7.1.220.0090.00615.61
7.1.210.0040.01115.81
7.1.200.0060.00515.62
7.1.190.0000.01515.83
7.1.180.0090.00616.04
7.1.170.0040.00715.53
7.1.160.0040.00815.56
7.1.150.0030.01015.69
7.1.140.0040.01415.71
7.1.130.0080.00315.91
7.1.120.0040.01115.73
7.1.110.0000.00815.80
7.1.100.0060.00916.80
7.1.90.0030.01015.91
7.1.80.0070.00715.93
7.1.70.0040.00616.49
7.1.60.0090.00917.58
7.1.50.0070.00716.49
7.1.40.0040.00715.81
7.1.30.0060.00915.76
7.1.20.0060.01015.68
7.1.10.0070.01015.43
7.1.00.0060.04119.12
7.0.330.0030.00915.39
7.0.320.0000.00915.45
7.0.310.0110.00415.27
7.0.300.0030.01015.43
7.0.290.0000.00915.35
7.0.280.0110.00015.57
7.0.270.0090.00315.64
7.0.260.0000.01115.13
7.0.250.0100.00315.39
7.0.240.0090.00615.49
7.0.230.0100.00315.34
7.0.220.0060.00615.34
7.0.210.0060.00315.32
7.0.200.0050.00716.09
7.0.190.0070.00315.62
7.0.180.0060.00615.45
7.0.170.0030.01015.20
7.0.160.0060.00315.43
7.0.150.0080.00815.48
7.0.140.0020.04418.82
7.0.130.0030.01015.54
7.0.120.0060.00615.60
7.0.110.0030.01015.50
7.0.100.0000.01115.48
7.0.90.0070.00315.38
7.0.80.0060.00915.45
7.0.70.0060.00615.51
7.0.60.0070.04017.71
7.0.50.0050.02116.81
7.0.40.0080.02816.67
7.0.30.0190.04216.79
7.0.20.0200.03716.68
7.0.10.0020.03016.81
7.0.00.0030.04816.81
5.6.400.0070.01114.64
5.6.390.0100.00314.57
5.6.380.0060.00914.57
5.6.370.0100.00014.69
5.6.360.0100.00714.38
5.6.350.0030.01014.72
5.6.340.0030.01414.46
5.6.330.0060.00914.70
5.6.320.0030.01014.56
5.6.310.0060.01014.23
5.6.300.0040.01114.38
5.6.290.0040.00814.26
5.6.280.0080.03817.71
5.6.270.0090.00614.61
5.6.260.0060.00314.52
5.6.250.0100.00614.56
5.6.240.0080.00814.47
5.6.230.0070.00714.59
5.6.220.0030.00814.60
5.6.210.0060.02317.36
5.6.200.0080.04116.32
5.6.190.0050.02317.44
5.6.180.0190.04217.61
5.6.170.0150.03517.43
5.6.160.0070.02317.37
5.6.150.0110.03716.25
5.6.140.0100.03816.31
5.6.130.0050.04116.27
5.6.120.0070.03317.60
5.6.110.0150.03717.71
5.6.100.0020.03217.71
5.6.90.0130.03817.73
5.6.80.0080.04517.46
5.6.70.0050.00514.25
5.6.60.0140.00314.33
5.6.50.0090.00314.36
5.6.40.0040.01114.13
5.6.30.0000.01514.29
5.6.20.0100.00614.22
5.6.10.0000.01414.58
5.6.00.0070.01014.16
5.5.380.0000.01414.50
5.5.370.0000.01314.21
5.5.360.0030.00914.71
5.5.350.0160.04617.22
5.5.340.0050.04116.16
5.5.330.0030.05017.22
5.5.320.0120.03717.39
5.5.310.0130.03517.31
5.5.300.0030.02716.16
5.5.290.0060.04316.16
5.5.280.0090.02517.53
5.5.270.0130.03717.62
5.5.260.0170.03417.54
5.5.250.0070.04717.34
5.5.240.0150.04217.19
5.5.230.0030.00614.27
5.5.220.0040.01114.28
5.5.210.0060.00814.21
5.5.200.0030.01014.35
5.5.190.0100.00314.37
5.5.180.0040.00814.51
5.5.170.0090.00614.38
5.5.160.0090.00314.39
5.5.150.0030.01314.22
5.5.140.0040.00814.38
5.5.130.0000.01114.19
5.5.120.0030.01214.35
5.5.110.0070.00714.25
5.5.100.0080.00414.05
5.5.90.0000.01014.17
5.5.80.0030.00714.58
5.5.70.0030.01014.57
5.5.60.0030.01014.51
5.5.50.0120.00614.41
5.5.40.0100.00714.22
5.5.30.0040.00814.46
5.5.20.0090.00014.58
5.5.10.0100.00014.01
5.5.00.0040.00814.30
5.4.450.0550.03415.86
5.4.440.0450.03515.71
5.4.430.0070.03215.91
5.4.420.0440.02715.93
5.4.410.0500.03315.65
5.4.400.0100.03215.72
5.4.390.0420.04115.54
5.4.380.0240.02515.49
5.4.370.0210.02515.55
5.4.360.0180.03015.50
5.4.350.0140.03415.50
5.4.340.0290.03515.49
5.4.330.0040.00712.25
5.4.320.0050.02112.38
5.4.310.0040.02512.38
5.4.300.0020.02312.38
5.4.290.0130.02712.37
5.4.280.0100.03712.32
5.4.270.0070.02912.32
5.4.260.0130.05812.32
5.4.250.0080.04412.32
5.4.240.0070.03912.32
5.4.230.0080.03212.32
5.4.220.0080.03812.32
5.4.210.0040.02712.31
5.4.200.0040.02512.32
5.4.190.0100.02212.31
5.4.180.0150.03212.31
5.4.170.0120.03712.32
5.4.160.0120.07612.31
5.4.150.0100.05212.31
5.4.140.0130.03412.15
5.4.130.0100.04812.15
5.4.120.0090.04312.13
5.4.110.0090.04312.13
5.4.100.0080.04312.13
5.4.90.0070.04912.12
5.4.80.0090.04212.13
5.4.70.0050.03412.12
5.4.60.0080.03112.12
5.4.50.0110.04412.13
5.4.40.0070.04612.12
5.4.30.0050.02812.12
5.4.20.0090.02612.12
5.4.10.0110.02412.12
5.4.00.0050.02811.86
5.3.290.0020.02912.52
5.3.280.0040.02512.48
5.3.270.0070.02412.48
5.3.260.0040.02612.48
5.3.250.0060.03412.48
5.3.240.0110.04912.48
5.3.230.0080.02712.48
5.3.220.0090.04412.46
5.3.210.0080.02812.46
5.3.200.0060.03712.46
5.3.190.0110.03212.46
5.3.180.0120.02412.46
5.3.170.0030.03112.46
5.3.160.0070.02112.46
5.3.150.0080.02612.46
5.3.140.0050.02312.46
5.3.130.0070.02112.45
5.3.120.0050.02212.45
5.3.110.0040.02312.45
5.3.100.0060.02112.19
5.3.90.0060.02312.18
5.3.80.0030.02312.18
5.3.70.0020.02412.17
5.3.60.0050.02212.17
5.3.50.0100.02612.14
5.3.40.0090.02712.14
5.3.30.0060.02712.12
5.3.20.0060.02112.01
5.3.10.0100.01612.00
5.3.00.0070.02011.99
5.2.170.0080.0319.23
5.2.160.0060.0329.24
5.2.150.0040.0339.23
5.2.140.0050.0309.23
5.2.130.0060.0279.19
5.2.120.0060.0309.20
5.2.110.0030.0339.20
5.2.100.0080.0279.20
5.2.90.0090.0329.19
5.2.80.0050.0319.19
5.2.70.0080.0269.19
5.2.60.0050.0299.14
5.2.50.0060.0349.11
5.2.40.0040.0419.09
5.2.30.0040.0349.07
5.2.20.0090.0269.05
5.2.10.0090.0438.96
5.2.00.0040.0428.82
5.1.60.0010.0318.11
5.1.50.0050.0268.10
5.1.40.0060.0248.08
5.1.30.0040.0288.43
5.1.20.0070.0288.45
5.1.10.0090.0248.18
5.1.00.0050.0268.18
5.0.50.0030.0236.66
5.0.40.0040.0276.52
5.0.30.0060.0336.33
5.0.20.0050.0206.30
5.0.10.0040.0196.28
5.0.00.0050.0306.27
4.4.90.0030.0164.78
4.4.80.0020.0294.75
4.4.70.0030.0234.75
4.4.60.0050.0214.75
4.4.50.0040.0184.77
4.4.40.0040.0274.71
4.4.30.0060.0204.76
4.4.20.0040.0174.84
4.4.10.0070.0204.84
4.4.00.0050.0264.76
4.3.110.0050.0214.67
4.3.100.0060.0244.66
4.3.90.0080.0244.63
4.3.80.0050.0294.59
4.3.70.0020.0164.63
4.3.60.0020.0164.63
4.3.50.0020.0174.63
4.3.40.0060.0354.54
4.3.30.0030.0163.30
4.3.20.0040.0153.28
4.3.10.0020.0223.23
4.3.00.0330.01310.54

preferences:
43.55 ms | 401 KiB | 5 Q