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 $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; } $key = caesar($array[$first_key],13); print_r('here'); // 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.48
8.3.50.0130.00621.93
8.3.40.0100.01018.72
8.3.30.0110.00419.17
8.3.20.0040.00420.34
8.3.10.0060.00321.78
8.3.00.0030.00519.38
8.2.180.0200.00316.75
8.2.170.0110.00422.96
8.2.160.0090.00618.84
8.2.150.0110.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00522.16
8.2.110.0070.00322.24
8.2.100.0060.00617.91
8.2.90.0040.00419.05
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0090.00018.05
8.2.50.0040.00418.07
8.2.40.0050.00319.88
8.2.30.0030.00618.06
8.2.20.0040.00417.75
8.2.10.0050.00318.13
8.2.00.0040.00417.77
8.1.280.0110.01125.92
8.1.270.0040.00423.82
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0040.00423.64
8.1.230.0090.00319.15
8.1.220.0030.00517.74
8.1.210.0050.00318.77
8.1.200.0030.00617.48
8.1.190.0000.00917.41
8.1.180.0080.00318.10
8.1.170.0070.00318.59
8.1.160.0050.00221.98
8.1.150.0080.00318.57
8.1.140.0040.00417.52
8.1.130.0000.00817.94
8.1.120.0040.00417.50
8.1.110.0060.00317.47
8.1.100.0040.00417.37
8.1.90.0000.00717.39
8.1.80.0050.00317.51
8.1.70.0030.00317.49
8.1.60.0000.00917.54
8.1.50.0000.00817.60
8.1.40.0030.00617.57
8.1.30.0030.00517.62
8.1.20.0040.00417.68
8.1.10.0000.00717.60
8.1.00.0070.00017.55
8.0.300.0050.00220.62
8.0.290.0040.00417.04
8.0.280.0000.00718.47
8.0.270.0050.00217.25
8.0.260.0000.00717.24
8.0.250.0030.00617.02
8.0.240.0050.00317.00
8.0.230.0080.00017.03
8.0.220.0070.00016.93
8.0.210.0030.00316.97
8.0.200.0000.00717.05
8.0.190.0030.00617.04
8.0.180.0040.00416.84
8.0.170.0070.00017.02
8.0.160.0040.00316.89
8.0.150.0040.00416.79
8.0.140.0040.00416.90
8.0.130.0030.00313.40
8.0.120.0060.00316.94
8.0.110.0040.00416.90
8.0.100.0060.00316.95
8.0.90.0050.00216.81
8.0.80.0050.01116.96
8.0.70.0040.00416.96
8.0.60.0070.00016.88
8.0.50.0000.00716.79
8.0.30.0120.00817.24
8.0.20.0130.00617.40
8.0.10.0000.00717.09
8.0.00.0080.01016.82
7.4.330.0000.00815.00
7.4.320.0000.00716.82
7.4.300.0040.00416.78
7.4.290.0030.00316.90
7.4.280.0000.00816.86
7.4.270.0070.00016.79
7.4.260.0080.00016.89
7.4.250.0080.00016.82
7.4.240.0040.00416.75
7.4.230.0000.00716.77
7.4.220.0100.00716.81
7.4.210.0040.01116.84
7.4.200.0040.00416.57
7.4.190.0030.00416.63
7.4.160.0160.00016.80
7.4.150.0100.00717.40
7.4.140.0050.01317.86
7.4.130.0080.00816.86
7.4.120.0110.01016.89
7.4.110.0120.00616.80
7.4.100.0100.01016.57
7.4.90.0100.00716.67
7.4.80.0160.00419.39
7.4.70.0160.00716.57
7.4.60.0080.00816.79
7.4.50.0000.00916.62
7.4.40.0060.00922.77
7.4.30.0090.00916.89
7.4.10.0110.00815.46
7.4.00.0050.01115.25
7.3.330.0000.00613.52
7.3.320.0000.00513.71
7.3.310.0000.00716.56
7.3.300.0030.00616.58
7.3.290.0140.00616.63
7.3.280.0070.01016.71
7.3.270.0070.01017.40
7.3.260.0160.00616.64
7.3.250.0150.00716.67
7.3.240.0100.01116.88
7.3.230.0060.01216.62
7.3.210.0070.01016.88
7.3.200.0080.01519.39
7.3.190.0100.01016.70
7.3.180.0030.01316.75
7.3.170.0090.00616.91
7.3.160.0100.00616.58
7.3.130.0030.01515.06
7.3.120.0100.00715.08
7.3.110.0050.01115.17
7.3.100.0030.01114.95
7.3.90.0060.01015.17
7.3.80.0050.00715.34
7.3.70.0080.00414.98
7.3.60.0050.00815.16
7.3.50.0080.00715.07
7.3.40.0050.01215.11
7.3.30.0040.00915.08
7.3.20.0080.00616.70
7.3.10.0080.00716.84
7.3.00.0050.00816.90
7.2.330.0160.00317.07
7.2.320.0120.00816.94
7.2.310.0000.01716.69
7.2.300.0070.01016.98
7.2.290.0100.00716.89
7.2.260.0080.01115.14
7.2.250.0110.00715.40
7.2.240.0090.00715.16
7.2.230.0050.00915.36
7.2.220.0090.00415.37
7.2.210.0100.00715.20
7.2.200.0000.01415.35
7.2.190.0030.01215.19
7.2.180.0090.00715.25
7.2.170.0050.01215.17
7.2.160.0040.00615.27
7.2.150.0100.00817.10
7.2.140.0070.00917.17
7.2.130.0070.00717.11
7.2.120.0070.00317.22
7.2.110.0080.00617.10
7.2.100.0100.00517.12
7.2.90.0060.00817.21
7.2.80.0080.00617.14
7.2.70.0060.00917.22
7.2.60.0120.00617.01
7.2.50.0080.00817.28
7.2.40.0070.00717.14
7.2.30.0060.00917.06
7.2.20.0080.00817.25
7.2.10.0110.00517.07
7.2.00.0070.00718.01
7.1.330.0050.01016.12
7.1.320.0070.00616.01
7.1.310.0050.00915.83
7.1.300.0080.00815.92
7.1.290.0110.00015.91
7.1.280.0070.00815.96
7.1.270.0020.01016.00
7.1.260.0090.00615.95
7.1.250.0030.01215.99
7.1.240.0130.00316.04
7.1.230.0040.01116.13
7.1.220.0060.00315.76
7.1.210.0050.00515.79
7.1.200.0040.00815.96
7.1.190.0060.00316.12
7.1.180.0070.01116.00
7.1.170.0060.00915.96
7.1.160.0060.00616.16
7.1.150.0030.01015.74
7.1.140.0070.01015.90
7.1.130.0000.01716.09
7.1.120.0060.00916.17
7.1.110.0000.01516.07
7.1.100.0080.00717.27
7.1.90.0090.00615.96
7.1.80.0140.00015.98
7.1.70.0070.00716.73
7.1.60.0130.00517.64
7.1.50.0070.01216.71
7.1.40.0130.00315.73
7.1.30.0000.01215.83
7.1.20.0000.01315.82
7.1.10.0000.01416.09
7.1.00.0050.04119.19
7.0.330.0060.00915.39
7.0.320.0000.00915.62
7.0.310.0130.00015.58
7.0.300.0150.00415.59
7.0.290.0120.00315.61
7.0.280.0060.00915.55
7.0.270.0100.00715.55
7.0.260.0080.00815.59
7.0.250.0060.00615.76
7.0.240.0090.00915.45
7.0.230.0070.00715.70
7.0.220.0090.00315.28
7.0.210.0030.01515.73
7.0.200.0070.00616.36
7.0.190.0040.01115.61
7.0.180.0080.00815.50
7.0.170.0080.00815.38
7.0.160.0000.01115.69
7.0.150.0070.01015.67
7.0.140.0070.03718.90
7.0.130.0070.00715.77
7.0.120.0030.01015.61
7.0.110.0040.01115.46
7.0.100.0120.03818.68
7.0.90.0070.04518.75
7.0.80.0080.04218.71
7.0.70.0100.04318.65
7.0.60.0120.02718.64
7.0.50.0050.04118.96
7.0.40.0120.03816.95
7.0.30.0070.04516.88
7.0.20.0060.03116.80
7.0.10.0020.04916.90
7.0.00.0050.04816.87
5.6.400.0000.00914.48
5.6.390.0070.00714.43
5.6.380.0070.00714.53
5.6.370.0040.01114.61
5.6.360.0090.00914.69
5.6.350.0060.00914.18
5.6.340.0170.00014.87
5.6.330.0040.00414.53
5.6.320.0100.00714.70
5.6.310.0040.01414.94
5.6.300.0030.00914.78
5.6.290.0040.01114.53
5.6.280.0090.03717.88
5.6.270.0030.01014.31
5.6.260.0040.01114.53
5.6.250.0030.03317.64
5.6.240.0070.04517.63
5.6.230.0080.02617.76
5.6.220.0030.04617.46
5.6.210.0050.02417.67
5.6.200.0070.04617.79
5.6.190.0050.03717.84
5.6.180.0050.04617.82
5.6.170.0070.04317.84
5.6.160.0050.04317.68
5.6.150.0070.04517.83
5.6.140.0030.04817.80
5.6.130.0120.02217.75
5.6.120.0080.04517.96
5.6.110.0070.04417.71
5.6.100.0070.04317.95
5.6.90.0100.04017.88
5.6.80.0050.03917.56
5.6.70.0120.03717.49
5.6.60.0120.03317.55
5.6.50.0090.03917.32
5.6.40.0020.04517.42
5.6.30.0100.03817.46
5.6.20.0080.02017.49
5.6.10.0050.04617.52
5.6.00.0050.04517.36
5.5.380.0090.03617.28
5.5.370.0050.03317.31
5.5.360.0070.04517.46
5.5.350.0020.03617.54
5.5.340.0080.04617.73
5.5.330.0090.04217.77
5.5.320.0030.03017.54
5.5.310.0110.02617.67
5.5.300.0050.04117.56
5.5.290.0060.03817.45
5.5.280.0130.03617.69
5.5.270.0070.04217.55
5.5.260.0060.04517.56
5.5.250.0040.03117.60
5.5.240.0070.03217.24
5.5.230.0020.04717.26
5.5.220.0080.03117.36
5.5.210.0070.04417.27
5.5.200.0070.04217.45
5.5.190.0050.03017.33
5.5.180.0080.04417.19
5.5.170.0060.00614.55
5.5.160.0050.04317.20
5.5.150.0120.03717.37
5.5.140.0040.03917.33
5.5.130.0130.04017.34
5.5.120.0090.04217.43
5.5.110.0020.04317.19
5.5.100.0100.04117.36
5.5.90.0080.04517.28
5.5.80.0040.04617.24
5.5.70.0100.03717.27
5.5.60.0080.04017.35
5.5.50.0070.04217.15
5.5.40.0090.04317.17
5.5.30.0080.04317.33
5.5.20.0070.04517.25
5.5.10.0110.04117.24
5.5.00.0080.04217.09
5.4.450.0070.03215.92
5.4.440.0080.04216.06
5.4.430.0090.02716.06
5.4.420.0030.04416.09
5.4.410.0040.04215.99
5.4.400.0050.04015.92
5.4.390.0130.03315.92
5.4.380.0150.03315.84
5.4.370.0120.03515.86
5.4.360.0050.04015.94
5.4.350.0030.04315.86
5.4.340.0080.03415.88
5.4.330.0070.00412.63
5.4.320.0050.04315.77
5.4.310.0070.03215.88
5.4.300.0050.04515.82
5.4.290.0000.04815.74
5.4.280.0030.04515.83
5.4.270.0010.04615.83
5.4.260.0020.03115.92
5.4.250.0130.03515.73
5.4.240.0110.03715.89
5.4.230.0050.04415.83
5.4.220.0030.02815.73
5.4.210.0100.03715.78
5.4.200.0080.03815.77
5.4.190.0100.03715.87
5.4.180.0100.03515.83
5.4.170.0050.04115.88
5.4.160.0070.04215.88
5.4.150.0080.04015.87
5.4.140.0100.03514.52
5.4.130.0040.04014.52
5.4.120.0050.04014.56
5.4.110.0050.04014.51
5.4.100.0110.03414.56
5.4.90.0050.02814.59
5.4.80.0070.03914.51
5.4.70.0140.03214.59
5.4.60.0030.04214.50
5.4.50.0060.04014.47
5.4.40.0080.02514.52
5.4.30.0030.02314.50
5.4.20.0100.01814.54
5.4.10.0090.02214.54
5.4.00.0070.02014.19
5.3.290.0050.04413.68
5.3.280.0030.04113.68
5.3.270.0050.04013.59
5.3.260.0090.03913.67
5.3.250.0040.03813.66
5.3.240.0020.04413.62
5.3.230.0050.04213.62
5.3.220.0030.03413.60
5.3.210.0070.04013.62
5.3.200.0060.04113.60
5.3.190.0060.04313.63
5.3.180.0080.04013.67
5.3.170.0090.03613.59
5.3.160.0070.04013.59
5.3.150.0050.04113.57
5.3.140.0030.04613.62
5.3.130.0000.02613.63
5.3.120.0140.01513.57
5.3.110.0030.02413.63
5.3.100.0030.02313.40
5.3.90.0070.04013.35
5.3.80.0030.02313.28
5.3.70.0010.02613.36
5.3.60.0020.02613.29
5.3.50.0040.03213.31
5.3.40.0100.01513.35
5.3.30.0030.02113.30
5.3.20.0050.02813.23
5.3.10.0040.02113.09
5.3.00.0050.01913.20
5.2.170.0100.02312.17
5.2.160.0070.02312.17
5.2.150.0100.03012.17
5.2.140.0030.02712.17
5.2.130.0030.03012.17
5.2.120.0070.04712.17
5.2.110.0100.04312.17
5.2.100.0030.04012.17
5.2.90.0030.02712.17
5.2.80.0070.05012.17
5.2.70.0030.05312.17
5.2.60.0000.04012.17
5.2.50.0030.02712.17
5.2.40.0000.03012.17
5.2.30.0000.04012.17
5.2.20.0000.02712.17
5.2.10.0030.02712.17
5.2.00.0030.02312.17
5.1.60.0100.04312.17
5.1.50.0030.02712.17
5.1.40.0000.02712.17
5.1.30.0000.02712.17
5.1.20.0070.02712.17
5.1.10.0000.02712.17
5.1.00.0000.02712.17
5.0.50.0030.02312.17
5.0.40.0000.02012.17
5.0.30.0070.02712.17
5.0.20.0000.02012.17
5.0.10.0030.02312.17
5.0.00.0000.03312.17
4.4.90.0000.03712.17
4.4.80.0030.01712.17
4.4.70.0000.01712.17
4.4.60.0070.03012.17
4.4.50.0000.01312.17
4.4.40.0100.02712.17
4.4.30.0000.01712.17
4.4.20.0000.01712.17
4.4.10.0030.01312.17
4.4.00.0000.02312.17
4.3.110.0030.01312.17
4.3.100.0000.01312.17
4.3.90.0000.01712.17
4.3.80.0000.02312.17
4.3.70.0070.00712.17
4.3.60.0030.01012.17
4.3.50.0000.02012.17
4.3.40.0000.02712.17
4.3.30.0000.02012.17
4.3.20.0000.01712.17
4.3.10.0000.01312.17
4.3.00.0000.01312.17

preferences:
61.68 ms | 401 KiB | 5 Q