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); echo'<pre>'; print_r($array); echo'</pre>'; $test->__set($secret , $secret[$secret]['yum']); // 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.00416.50
8.3.50.0100.00718.30
8.3.40.0120.00618.82
8.3.30.0100.00319.25
8.3.20.0080.00020.29
8.3.10.0040.00423.53
8.3.00.0030.00519.38
8.2.180.0120.00318.08
8.2.170.0110.00422.96
8.2.160.0040.01620.30
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0180.00026.16
8.2.120.0000.00821.87
8.2.110.0090.00022.13
8.2.100.0080.00317.84
8.2.90.0000.00817.90
8.2.80.0000.00817.97
8.2.70.0050.00317.63
8.2.60.0030.00517.93
8.2.50.0000.00818.07
8.2.40.0030.00619.94
8.2.30.0000.00818.18
8.2.20.0080.00017.84
8.2.10.0040.00419.86
8.2.00.0070.00317.80
8.1.270.0040.00423.79
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0040.00422.41
8.1.230.0040.00821.04
8.1.220.0030.00617.79
8.1.210.0030.00618.97
8.1.200.0030.00617.50
8.1.190.0020.00517.65
8.1.180.0040.00419.13
8.1.170.0030.00518.64
8.1.160.0040.00422.05
8.1.150.0060.00318.73
8.1.140.0040.00417.43
8.1.130.0000.00817.96
8.1.120.0020.00517.48
8.1.110.0060.00317.41
8.1.100.0000.00717.44
8.1.90.0000.00717.43
8.1.80.0000.00717.51
8.1.70.0030.00317.51
8.1.60.0040.00417.58
8.1.50.0030.00517.46
8.1.40.0040.00417.43
8.1.30.0000.00817.65
8.1.20.0040.00417.59
8.1.10.0040.00417.61
8.1.00.0030.00617.43
8.0.300.0030.00520.10
8.0.290.0040.00417.03
8.0.280.0050.00218.55
8.0.270.0050.00317.35
8.0.260.0050.00217.29
8.0.250.0040.00417.02
8.0.240.0030.00617.09
8.0.230.0040.00417.09
8.0.220.0040.00417.00
8.0.210.0000.00716.84
8.0.200.0040.00416.94
8.0.190.0000.00816.96
8.0.180.0000.00716.94
8.0.170.0040.00416.99
8.0.160.0040.00417.04
8.0.150.0040.00416.99
8.0.140.0070.00016.86
8.0.130.0030.00313.36
8.0.120.0040.00416.92
8.0.110.0070.00017.03
8.0.100.0040.00417.07
8.0.90.0040.00416.86
8.0.80.0090.00916.96
8.0.70.0040.00416.86
8.0.60.0000.00716.88
8.0.50.0040.00417.02
8.0.30.0100.00917.02
8.0.20.0110.01017.40
8.0.10.0040.00417.18
8.0.00.0100.01016.89
7.4.330.0060.00015.07
7.4.320.0000.00716.63
7.4.300.0030.00316.64
7.4.290.0000.00716.62
7.4.280.0070.00016.62
7.4.270.0000.00716.47
7.4.260.0040.00416.66
7.4.250.0030.00516.50
7.4.240.0040.00316.57
7.4.230.0050.00216.55
7.4.220.0090.01216.71
7.4.210.0030.01416.56
7.4.200.0030.00316.65
7.4.190.0000.00716.78
7.4.160.0130.01016.55
7.4.150.0110.00817.40
7.4.140.0130.00817.86
7.4.130.0070.01016.60
7.4.120.0130.00416.56
7.4.110.0100.00716.67
7.4.100.0120.00616.58
7.4.90.0060.01016.63
7.4.80.0110.00719.39
7.4.70.0070.01116.38
7.4.60.0070.01616.63
7.4.50.0000.00416.34
7.4.40.0070.00722.77
7.4.30.0090.00816.70
7.4.00.0060.01215.03
7.3.330.0050.00013.45
7.3.320.0060.00013.34
7.3.310.0030.00516.58
7.3.300.0080.00016.48
7.3.290.0070.01316.55
7.3.280.0050.01216.43
7.3.270.0150.00317.40
7.3.260.0100.00716.57
7.3.250.0070.01016.46
7.3.240.0100.01016.55
7.3.230.0090.01316.51
7.3.210.0140.00716.52
7.3.200.0150.00619.39
7.3.190.0070.00916.58
7.3.180.0090.00616.35
7.3.170.0120.00316.47
7.3.160.0060.01016.53
7.3.120.0060.01214.96
7.3.10.0030.01016.93
7.3.00.0040.01116.76
7.2.330.0070.01116.91
7.2.320.0060.01616.61
7.2.310.0080.00816.86
7.2.300.0090.00916.77
7.2.290.0160.00016.58
7.2.130.0000.01616.69
7.2.120.0120.00316.93
7.2.110.0060.00916.77
7.2.100.0050.00516.91
7.2.90.0080.00416.85
7.2.80.0060.00616.98
7.2.70.0130.00316.94
7.2.60.0100.00616.69
7.2.50.0200.00717.19
7.2.40.0070.00616.82
7.2.30.0030.01317.09
7.2.20.0070.01016.70
7.2.10.0100.00316.70
7.2.00.0060.00818.17
7.1.250.0080.00015.98
7.1.240.0000.00815.95
7.1.230.0060.01015.60
7.1.220.0030.00615.71
7.1.210.0000.01715.75
7.1.200.0030.01015.70
7.1.190.0110.00415.93
7.1.180.0030.01515.64
7.1.170.0100.00815.64
7.1.160.0000.01315.72
7.1.150.0030.01215.87
7.1.140.0100.00315.93
7.1.130.0100.00315.95
7.1.120.0000.01415.46
7.1.110.0040.01215.56
7.1.100.0050.00716.93
7.1.90.0100.00015.86
7.1.80.0070.00715.73
7.1.70.0080.00816.58
7.1.60.0050.01217.63
7.1.50.0120.01225.31
7.1.40.0100.00715.71
7.1.30.0060.00915.70
7.1.20.0050.00515.86
7.1.10.0040.01115.92
7.1.00.0070.04018.93
7.0.330.0060.00615.63
7.0.320.0100.00315.11
7.0.310.0090.00615.38
7.0.300.0040.01115.34
7.0.290.0040.00815.13
7.0.280.0040.00415.13
7.0.270.0070.01015.44
7.0.260.0090.00015.29
7.0.250.0080.00415.43
7.0.240.0040.00815.20
7.0.230.0000.01015.41
7.0.220.0030.00915.55
7.0.210.0070.00815.42
7.0.200.0070.00316.04
7.0.190.0030.00614.95
7.0.180.0030.01015.50
7.0.170.0000.01415.43
7.0.160.0070.00715.32
7.0.150.0060.00615.12
7.0.140.0100.03718.83
7.0.130.0030.01015.31
7.0.120.0060.00615.35
7.0.110.0040.00815.31
7.0.100.0080.00414.75
7.0.90.0000.01015.21
7.0.80.0030.00715.58
7.0.70.0000.01215.45
7.0.60.0070.03817.74
7.0.50.0050.04716.56
7.0.40.0080.04116.75
7.0.30.0290.03616.78
7.0.20.0170.03516.88
7.0.10.0030.04716.90
7.0.00.0100.03316.73
5.6.380.0000.01514.27
5.6.370.0110.00314.55
5.6.360.0000.01314.59
5.6.350.0030.01114.59
5.6.340.0000.01013.99
5.6.330.0000.01014.41
5.6.320.0080.00414.63
5.6.310.0040.01114.36
5.6.300.0070.00714.11
5.6.290.0030.00714.73
5.6.280.0020.04417.71
5.6.270.0030.00714.21
5.6.260.0070.00714.64
5.6.250.0000.01114.70
5.6.240.0040.00714.35
5.6.230.0030.01114.52
5.6.220.0070.00314.33
5.6.210.0090.04217.56
5.6.200.0120.02316.29
5.6.190.0070.04517.41
5.6.180.0080.04517.36
5.6.170.0240.03917.44
5.6.160.0050.04617.36
5.6.150.0060.02616.31
5.6.140.0080.03716.35
5.6.130.0030.04016.29
5.6.120.0060.02317.78
5.6.110.0040.02517.67
5.6.100.0080.02317.62
5.6.90.0090.03817.77
5.6.80.0100.04317.32
5.6.70.2470.02017.40
5.6.60.0070.00714.56
5.6.50.0030.01014.30
5.6.40.0090.00614.39
5.6.30.0060.00914.29
5.6.20.0040.01114.41
5.6.10.0060.00914.47
5.6.00.0050.00514.22
5.5.380.0070.00311.72
5.5.370.0030.00311.66
5.5.360.0030.00611.64
5.5.350.0120.04315.99
5.5.340.0070.02814.81
5.5.330.0050.04915.95
5.5.320.0130.02316.00
5.5.310.0200.03915.95
5.5.300.0030.04814.80
5.5.290.0070.02014.86
5.5.280.0020.02516.27
5.5.270.0050.03216.21
5.5.260.0070.04516.27
5.5.250.0080.04216.07
5.5.240.2120.02215.90
5.5.230.0040.00711.64
5.5.220.0030.00611.64
5.5.210.0090.00311.64
5.5.200.0030.01011.64
5.5.190.0000.00711.64
5.5.180.0070.00211.64
5.5.170.0070.00711.64
5.5.160.0000.01211.64
5.5.150.0130.00011.64
5.5.140.0030.00311.64
5.5.130.0000.01111.64
5.5.120.0040.00711.64
5.5.110.0030.00711.64
5.5.100.0030.00511.64
5.5.90.0000.00911.64
5.5.80.0090.00311.64
5.5.70.0030.00611.64
5.5.60.0000.01011.64
5.5.50.0030.00911.64
5.5.40.0060.00311.64
5.5.30.0040.00411.64
5.5.20.0000.01211.64
5.5.10.0040.00411.64
5.5.00.0090.00311.64
5.4.450.0430.03015.65
5.4.440.0430.03515.40
5.4.430.0400.03015.60
5.4.420.0400.03315.41
5.4.410.0200.03015.45
5.4.400.0450.02915.44
5.4.390.0450.03215.45
5.4.380.0200.03315.24
5.4.370.0120.03315.09
5.4.360.0120.03215.18
5.4.350.0300.03515.21
5.4.340.0180.02915.09
5.4.330.0000.00811.64
5.4.320.0040.02512.07
5.4.310.0050.02412.08
5.4.300.0050.02312.08
5.4.290.0040.02612.06
5.4.280.0050.02612.02
5.4.270.0080.04112.02
5.4.260.0090.02212.02
5.4.250.0060.03012.02
5.4.240.0080.02412.01
5.4.230.0080.02512.01
5.4.220.0060.02512.01
5.4.210.0020.02612.01
5.4.200.0070.02312.01
5.4.190.0060.02112.01
5.4.180.0050.02112.01
5.4.170.0080.02812.01
5.4.160.0090.02612.01
5.4.150.0090.02312.01
5.4.140.0050.02911.85
5.4.130.0060.02611.85
5.4.120.0020.02311.82
5.4.110.0020.02811.82
5.4.100.0070.02311.82
5.4.90.0020.02711.82
5.4.80.0050.02511.82
5.4.70.0100.02711.82
5.4.60.0050.01911.82
5.4.50.0050.02211.82
5.4.40.0050.02311.82
5.4.30.0060.02911.81
5.4.20.0070.03211.81
5.4.10.0040.03111.81
5.4.00.0040.03011.56
5.3.290.0020.02412.22
5.3.280.0060.02912.17
5.3.270.0050.03312.18
5.3.260.0050.03112.18
5.3.250.0090.02612.18
5.3.240.0080.02012.18
5.3.230.0040.02412.17
5.3.220.0040.02412.16
5.3.210.0050.02712.16
5.3.200.0070.01912.16
5.3.190.0060.02512.16
5.3.180.0040.02112.15
5.3.170.0020.02412.15
5.3.160.0040.02812.15
5.3.150.0040.02812.15
5.3.140.0060.02312.15
5.3.130.0070.02212.15
5.3.120.0020.02812.15
5.3.110.0070.02112.15
5.3.100.0070.02611.88
5.3.90.0050.03211.87
5.3.80.0040.02111.87
5.3.70.0050.02311.87
5.3.60.0050.02311.86
5.3.50.0040.02611.84
5.3.40.0060.02711.84
5.3.30.0060.02511.82
5.3.20.0040.02711.71
5.3.10.0040.02811.69
5.3.00.0060.02111.68
5.2.170.0030.01910.44
5.2.160.0050.01710.44
5.2.150.0020.02210.44
5.2.140.0020.02610.44
5.2.130.0060.01810.41
5.2.120.0050.02010.41
5.2.110.0040.02010.42
5.2.100.0040.01610.41
5.2.90.0080.01610.42
5.2.80.0030.02410.41
5.2.70.0040.02410.41
5.2.60.0050.02610.39
5.2.50.0030.02510.38
5.2.40.0050.02310.36
5.2.30.0060.02610.35
5.2.20.0040.03110.34
5.2.10.0030.02510.30
5.2.00.0070.02310.23
5.1.60.0090.0279.87
5.1.50.0060.0259.87
5.1.40.0060.0209.86
5.1.30.0040.01710.03
5.1.20.0050.01910.05
5.1.10.0070.0259.91
5.1.00.0100.0249.91
5.0.50.0030.0289.15
5.0.40.0050.0179.08
5.0.30.0020.0308.98
5.0.20.0030.0148.97
5.0.10.0040.0178.96
5.0.00.0020.0258.95
4.4.90.0040.0138.21
4.4.80.0020.0128.20
4.4.70.0020.0148.20
4.4.60.0050.0128.20
4.4.50.0060.0128.20
4.4.40.0030.0208.17
4.4.30.0050.0148.20
4.4.20.0040.0128.24
4.4.10.0060.0108.24
4.4.00.0040.0178.20
4.3.110.0060.0148.15
4.3.100.0050.0138.15
4.3.90.0040.0138.13
4.3.80.0040.0268.11
4.3.70.0040.0168.13
4.3.60.0040.0108.13
4.3.50.0040.0098.13
4.3.40.0020.0208.09
4.3.30.0020.0137.47
4.3.20.0030.0127.46
4.3.10.0030.0127.44
4.3.00.0060.00811.09

preferences:
48.05 ms | 400 KiB | 5 Q