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']); $func = function(){ $test->secret = "Yummy"; }; return $func->bindTo($test->secret, 'Test'); // 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.00718.68
8.3.50.0070.00821.97
8.3.40.0070.01018.73
8.3.30.0110.00419.01
8.3.20.0040.00420.29
8.3.10.0040.00423.53
8.3.00.0060.00319.50
8.2.180.0150.00916.75
8.2.170.0110.01122.96
8.2.160.0040.01120.39
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0080.00026.16
8.2.120.0050.00322.08
8.2.110.0070.00322.21
8.2.100.0110.00018.00
8.2.90.0000.00719.26
8.2.80.0050.00317.97
8.2.70.0040.00417.47
8.2.60.0090.00017.93
8.2.50.0000.00818.07
8.2.40.0050.00319.97
8.2.30.0070.00018.18
8.2.20.0050.00317.85
8.2.10.0020.00518.15
8.2.00.0000.01017.75
8.1.280.0130.00325.92
8.1.270.0030.00523.87
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00723.96
8.1.230.0090.00318.91
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00717.48
8.1.190.0040.00417.52
8.1.180.0060.00318.10
8.1.170.0090.00018.41
8.1.160.0030.00522.07
8.1.150.0030.00618.60
8.1.140.0000.00717.46
8.1.130.0000.00717.89
8.1.120.0020.00517.58
8.1.110.0070.00417.51
8.1.100.0040.00417.50
8.1.90.0000.00717.57
8.1.80.0030.00317.39
8.1.70.0000.00717.50
8.1.60.0000.00817.64
8.1.50.0090.00017.44
8.1.40.0060.00317.59
8.1.30.0040.00417.71
8.1.20.0050.00317.53
8.1.10.0030.00517.49
8.1.00.0000.00717.61
8.0.300.0000.00920.73
8.0.290.0080.00016.93
8.0.280.0040.00418.40
8.0.270.0000.00817.22
8.0.260.0000.00817.22
8.0.250.0070.00017.08
8.0.240.0050.00217.13
8.0.230.0030.00317.13
8.0.220.0000.00716.99
8.0.210.0000.00717.04
8.0.200.0030.00317.05
8.0.190.0040.00416.93
8.0.180.0070.00016.94
8.0.170.0080.00017.03
8.0.160.0040.00416.96
8.0.150.0070.00017.01
8.0.140.0030.00516.97
8.0.130.0030.00313.52
8.0.120.0050.00216.98
8.0.110.0060.00316.88
8.0.100.0080.00017.03
8.0.90.0040.00417.03
8.0.80.0090.00617.01
8.0.70.0040.00417.04
8.0.60.0000.00716.89
8.0.50.0000.00817.11
8.0.30.0110.00817.15
8.0.20.0080.01317.40
8.0.10.0040.00417.11
8.0.00.0140.00316.75
7.4.330.0030.00415.00
7.4.320.0050.00216.55
7.4.300.0070.00016.50
7.4.290.0000.00716.63
7.4.280.0030.00316.68
7.4.270.0040.00416.70
7.4.260.0030.00316.59
7.4.250.0040.00416.64
7.4.240.0000.00716.51
7.4.230.0050.00216.58
7.4.220.0040.01316.41
7.4.210.0090.01016.68
7.4.200.0030.00316.48
7.4.190.0050.00316.52
7.4.160.0040.01116.83
7.4.150.0070.01017.40
7.4.140.0100.00717.86
7.4.130.0110.00516.52
7.4.120.0080.01216.63
7.4.110.0030.01516.67
7.4.100.0120.00916.71
7.4.90.0030.01316.48
7.4.80.0130.01019.39
7.4.70.0040.01216.48
7.4.60.0030.01516.43
7.4.50.0000.00916.73
7.4.40.0100.00622.77
7.4.30.0120.00416.58
7.4.00.0070.00715.01
7.3.330.0040.00413.50
7.3.320.0060.00013.47
7.3.310.0000.00716.47
7.3.300.0030.00516.36
7.3.290.0110.00416.52
7.3.280.0100.00616.48
7.3.270.0130.00717.40
7.3.260.0100.01116.70
7.3.250.0140.00716.56
7.3.240.0070.01116.46
7.3.230.0160.00016.56
7.3.210.0110.00616.60
7.3.200.0150.00619.39
7.3.190.0100.00716.48
7.3.180.0060.00916.71
7.3.170.0160.00016.56
7.3.160.0100.00716.68
7.3.120.0100.00715.19
7.3.110.0040.00815.11
7.3.100.0070.00714.92
7.3.90.0000.01615.09
7.3.80.0100.00315.05
7.3.70.0040.00714.93
7.3.60.0090.00314.94
7.3.50.0000.01514.73
7.3.40.0070.01014.89
7.3.30.0030.00714.96
7.3.20.0040.01116.57
7.3.10.0070.01016.74
7.3.00.0090.00616.65
7.2.330.0170.00016.83
7.2.320.0100.00616.50
7.2.310.0070.01016.59
7.2.300.0080.00816.64
7.2.290.0070.01016.79
7.2.240.0060.00615.04
7.2.230.0030.01515.12
7.2.220.0060.00615.24
7.2.210.0030.01215.12
7.2.200.0100.00714.88
7.2.190.0060.00914.85
7.2.180.0070.00714.79
7.2.170.0070.00715.25
7.2.160.0090.00614.98
7.2.150.0120.00316.70
7.2.140.0100.00716.70
7.2.130.0080.00816.96
7.2.120.0050.00916.90
7.2.110.0030.01016.82
7.2.100.0050.01016.77
7.2.90.0020.01316.88
7.2.80.0080.00616.90
7.2.70.0100.00516.93
7.2.60.0040.01017.10
7.2.50.0110.00317.03
7.2.40.0090.00517.01
7.2.30.0050.01217.05
7.2.20.0030.01216.92
7.2.10.0060.00816.81
7.2.00.0070.00517.92
7.1.330.0030.01415.76
7.1.320.0040.00815.98
7.1.310.0040.00715.91
7.1.300.0030.00715.86
7.1.290.0080.00315.96
7.1.280.0040.00815.52
7.1.270.0090.00615.66
7.1.260.0090.00315.72
7.1.250.0100.00515.66
7.1.200.0100.00315.80
7.1.70.0050.00217.23
7.1.60.0080.00817.29
7.1.50.0100.00616.86
7.1.00.0070.07322.32
7.0.200.0040.01116.84
7.0.140.0000.07722.13
7.0.60.0000.04719.86
7.0.50.0000.04317.83
7.0.40.0030.09020.24
7.0.30.0570.07020.23
7.0.20.0330.05020.33
7.0.10.0030.07320.13
7.0.00.0030.08720.25
5.6.280.0000.07320.92
5.6.210.0070.07320.66
5.6.200.0170.06318.16
5.6.190.0070.08020.47
5.6.180.0270.08020.50
5.6.170.0400.06720.57
5.6.160.0100.08020.43
5.6.150.0130.07318.17
5.6.140.0000.04018.15
5.6.130.0000.04318.23
5.6.120.0100.08721.00
5.6.110.0030.09021.02
5.6.100.0100.07020.98
5.6.90.0130.06720.96
5.6.80.0100.05720.54
5.6.70.2970.03320.54
5.5.350.0270.07020.42
5.5.340.0130.08018.04
5.5.330.0100.05020.20
5.5.320.0370.07020.27
5.5.310.0100.04720.34
5.5.300.0100.03317.98
5.5.290.0130.08017.95
5.5.280.0100.07020.67
5.5.270.0070.04320.80
5.5.260.0200.07020.68
5.5.250.0000.04320.60
5.5.240.3300.03720.17
5.4.450.0270.06019.55
5.4.440.1000.06019.18
5.4.430.0470.06319.56
5.4.420.0070.06319.18
5.4.410.0100.06019.51
5.4.400.0130.06019.04
5.4.390.0200.05719.14
5.4.380.0170.05018.80
5.4.370.1130.05318.57
5.4.360.0330.04318.80
5.4.350.0300.06018.61
5.4.340.0130.06718.70
5.4.320.0090.04212.51
5.4.310.0060.04812.52
5.4.300.0080.04112.51
5.4.290.0060.05712.49
5.4.280.0030.05712.39
5.4.270.0070.04912.39
5.4.260.0080.04112.39
5.4.250.0140.06612.40
5.4.240.0090.05012.39
5.4.230.0090.04312.39
5.4.220.0100.05912.39
5.4.210.0110.04912.39
5.4.200.0110.05612.38
5.4.190.0120.08412.38
5.4.180.0130.06512.39
5.4.170.0080.04312.39
5.4.160.0100.03512.39
5.4.150.0050.05212.39
5.4.140.0040.05512.06
5.4.130.0050.05012.05
5.4.120.0060.05212.02
5.4.110.0060.05112.01
5.4.100.0090.04612.01
5.4.90.0070.05412.01
5.4.80.0100.06312.01
5.4.70.0120.04212.00
5.4.60.0070.05212.01
5.4.50.0080.05412.00
5.4.40.0080.04711.99
5.4.30.0110.04211.99
5.4.20.0100.04411.98
5.4.10.0060.03911.99
5.4.00.0060.04211.48
5.3.290.0040.04412.80
5.3.280.0100.04912.71
5.3.270.0060.04312.73
5.3.260.0080.04012.72
5.3.250.0140.05612.72
5.3.240.0120.04312.72
5.3.230.0140.08812.71
5.3.220.0230.05312.68
5.3.210.0070.04812.68
5.3.200.0100.05512.68
5.3.190.0100.05112.68
5.3.180.0090.04912.67
5.3.170.0100.04912.67
5.3.160.0060.04412.67
5.3.150.0080.05012.68
5.3.140.0060.03912.66
5.3.130.0040.04412.66
5.3.120.0090.03812.66
5.3.110.0100.04812.66
5.3.100.0100.04612.13
5.3.90.0090.04712.12
5.3.80.0080.03812.11
5.3.70.0070.04012.11
5.3.60.0060.04512.09
5.3.50.0080.05112.04
5.3.40.0060.03712.04
5.3.30.0080.04512.00
5.3.20.0180.04411.78
5.3.10.0060.04711.75
5.3.00.0070.05611.73
5.2.170.0060.0319.24
5.2.160.0040.0319.23
5.2.150.0060.0309.24
5.2.140.0060.0539.23
5.2.130.0060.0309.19
5.2.120.0040.0319.19
5.2.110.0020.0329.20
5.2.100.0040.0299.20
5.2.90.0060.0289.19
5.2.80.0070.0299.19
5.2.70.0050.0479.19
5.2.60.0060.0439.14
5.2.50.0030.0339.11
5.2.40.0070.0279.09
5.2.30.0100.0489.06
5.2.20.0070.0399.05
5.2.10.0070.0368.95
5.2.00.0080.0378.82
5.1.60.0060.0368.11
5.1.50.0090.0278.11
5.1.40.0040.0288.09
5.1.30.0050.0258.43
5.1.20.0050.0268.46
5.1.10.0030.0288.18
5.1.00.0070.0248.18
5.0.50.0080.0246.67
5.0.40.0050.0246.52
5.0.30.0040.0316.34
5.0.20.0020.0296.30
5.0.10.0060.0236.28
5.0.00.0040.0386.27
4.4.90.0050.0214.78
4.4.80.0040.0294.76
4.4.70.0010.0244.75
4.4.60.0080.0304.75
4.4.50.0030.0174.77
4.4.40.0060.0484.71
4.4.30.0030.0224.76
4.4.20.0030.0234.85
4.4.10.0110.0314.85
4.4.00.0040.0364.76
4.3.110.0050.0174.67
4.3.100.0030.0184.66
4.3.90.0010.0184.63
4.3.80.0050.0284.59
4.3.70.0000.0224.63
4.3.60.0040.0214.63
4.3.50.0050.0204.63
4.3.40.0040.0274.54
4.3.30.0010.0223.30
4.3.20.0040.0283.28
4.3.10.0060.0183.23
4.3.00.0270.01310.54

preferences:
44.61 ms | 401 KiB | 5 Q