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 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]); //used this to figure out the count: // http://rumkin.com/tools/cipher/caesar.php $secret = caesar($array[$first_key],13); //print_r('the secret is:'.$secret); //$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.0080.00817.00
8.3.50.0100.01222.12
8.3.40.0120.00618.83
8.3.30.0130.00319.17
8.3.20.0040.00420.29
8.3.10.0040.00423.53
8.3.00.0030.00619.38
8.2.180.0090.00918.54
8.2.170.0110.00422.96
8.2.160.0040.01120.38
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.01026.16
8.2.120.0070.00022.25
8.2.110.0030.00622.07
8.2.100.0080.00417.97
8.2.90.0000.00819.26
8.2.80.0000.00918.04
8.2.70.0040.00417.75
8.2.60.0050.00318.05
8.2.50.0030.00618.07
8.2.40.0090.00019.95
8.2.30.0080.00018.26
8.2.20.0040.00417.84
8.2.10.0080.00018.02
8.2.00.0040.00717.72
8.1.280.0140.00425.92
8.1.270.0040.00423.93
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.70
8.1.230.0080.00319.16
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0030.00617.35
8.1.190.0040.00417.41
8.1.180.0040.00418.10
8.1.170.0040.00418.46
8.1.160.0040.00422.01
8.1.150.0000.00818.59
8.1.140.0050.00217.37
8.1.130.0080.00017.89
8.1.120.0030.00317.41
8.1.110.0040.00417.57
8.1.100.0040.00417.43
8.1.90.0050.00217.56
8.1.80.0040.00417.54
8.1.70.0030.00317.36
8.1.60.0030.00717.52
8.1.50.0040.00417.52
8.1.40.0040.00417.56
8.1.30.0050.00317.63
8.1.20.0050.00317.66
8.1.10.0040.00417.66
8.1.00.0040.00417.57
8.0.300.0040.00418.77
8.0.290.0000.00817.18
8.0.280.0050.00218.49
8.0.270.0020.00517.36
8.0.260.0030.00317.18
8.0.250.0000.00617.11
8.0.240.0080.00017.11
8.0.230.0040.00416.97
8.0.220.0000.00816.89
8.0.210.0000.00816.97
8.0.200.0040.00417.05
8.0.190.0000.00917.11
8.0.180.0080.00016.91
8.0.170.0000.00817.11
8.0.160.0070.00016.98
8.0.150.0050.00316.85
8.0.140.0040.00316.96
8.0.130.0000.00613.49
8.0.120.0000.00816.88
8.0.110.0030.00516.92
8.0.100.0000.00716.87
8.0.90.0030.00317.07
8.0.80.0100.00716.95
8.0.70.0060.00316.87
8.0.60.0040.00416.87
8.0.50.0040.00416.95
8.0.30.0110.01117.01
8.0.20.0130.01017.40
8.0.10.0020.00517.17
8.0.00.0070.01016.86
7.4.330.0050.00015.12
7.4.320.0000.00616.70
7.4.300.0030.00316.45
7.4.290.0030.00316.55
7.4.280.0030.00316.61
7.4.270.0050.00316.63
7.4.260.0030.00316.63
7.4.250.0030.00516.44
7.4.240.0020.00516.67
7.4.230.0030.00316.76
7.4.220.0070.02116.69
7.4.210.0090.00516.59
7.4.200.0000.00716.75
7.4.190.0070.00016.52
7.4.160.0150.00016.36
7.4.150.0040.01517.40
7.4.140.0110.00717.86
7.4.130.0070.01216.67
7.4.120.0070.01116.58
7.4.110.0090.00816.69
7.4.100.0070.01016.57
7.4.90.0090.00916.46
7.4.80.0090.01519.39
7.4.70.0080.00816.65
7.4.60.0110.01116.66
7.4.50.0030.00316.63
7.4.40.0020.01222.77
7.4.30.0100.00616.70
7.4.00.0060.00915.16
7.3.330.0030.00313.46
7.3.320.0040.00413.45
7.3.310.0070.00016.36
7.3.300.0000.00916.52
7.3.290.0140.00716.47
7.3.280.0080.00916.49
7.3.270.0080.00817.40
7.3.260.0110.00616.73
7.3.250.0110.01116.48
7.3.240.0150.00316.47
7.3.230.0070.01316.74
7.3.210.0120.00616.52
7.3.200.0120.00719.39
7.3.190.0140.00316.50
7.3.180.0140.00716.62
7.3.170.0050.01116.68
7.3.160.0100.00716.65
7.3.120.0090.00615.14
7.3.10.0000.01216.57
7.3.00.0190.00016.58
7.2.330.0030.01416.95
7.2.320.0130.00416.88
7.2.310.0070.01616.93
7.2.300.0100.00716.82
7.2.290.0120.00616.51
7.2.130.0180.00816.90
7.2.120.0030.00716.76
7.2.110.0100.01316.29
7.2.100.0130.00416.82
7.2.90.0160.00616.54
7.2.80.0030.01316.87
7.2.70.0000.01816.82
7.2.60.0210.00416.55
7.2.50.0190.00616.83
7.2.40.0060.00916.80
7.2.30.0160.00716.70
7.2.20.0140.01416.68
7.2.10.0190.00616.82
7.2.00.0110.01617.00
7.1.250.0180.00615.46
7.1.200.0070.00715.89
7.1.100.0090.00618.21
7.1.70.0100.00317.18
7.1.60.0090.01619.46
7.1.50.0060.01616.68
7.1.00.0000.09322.38
7.0.200.0030.00616.44
7.0.140.0030.07022.00
7.0.60.0030.08019.81
7.0.50.0170.06017.89
7.0.40.0030.04720.27
7.0.30.0500.05320.06
7.0.20.0300.04720.07
7.0.10.0100.04720.07
7.0.00.0070.08320.06
5.6.280.0100.07021.16
5.6.210.0100.03720.52
5.6.200.0000.06018.16
5.6.190.0000.05320.77
5.6.180.0200.08020.46
5.6.170.0300.07320.45
5.6.160.0070.04020.51
5.6.150.0030.05318.13
5.6.140.0100.05018.14
5.6.130.0100.03718.17
5.6.120.0070.04020.98
5.6.110.0170.07721.13
5.6.100.0070.08720.99
5.6.90.0030.08721.14
5.6.80.0170.07320.50
5.6.70.4430.04020.53
5.5.350.0300.07720.45
5.5.340.0030.04317.99
5.5.330.0030.04320.40
5.5.320.0330.07720.51
5.5.310.0170.05320.42
5.5.300.0030.04017.94
5.5.290.0030.04718.08
5.5.280.0100.08020.89
5.5.270.0000.09720.85
5.5.260.0030.04020.80
5.5.250.0100.04720.68
5.5.240.3800.04020.08
5.4.450.0730.05719.47
5.4.440.0900.05019.37
5.4.430.1100.05319.62
5.4.420.0700.05719.59
5.4.410.0130.05019.05
5.4.400.0800.05019.27
5.4.390.0770.05719.30
5.4.380.0430.05018.61
5.4.370.1800.06018.80
5.4.360.0230.06018.78
5.4.350.0470.07018.56
5.4.340.0500.05318.79
5.4.320.0070.04112.52
5.4.310.0050.03912.51
5.4.300.0030.03912.52
5.4.290.0050.03912.50
5.4.280.0030.04012.39
5.4.270.0070.04812.40
5.4.260.0090.05212.39
5.4.250.0110.04712.39
5.4.240.0060.05212.39
5.4.230.0050.04512.39
5.4.220.0080.03712.38
5.4.210.0050.03712.39
5.4.200.0050.04012.39
5.4.190.0090.03512.38
5.4.180.0110.03712.38
5.4.170.0050.03712.38
5.4.160.0070.03412.38
5.4.150.0030.03812.38
5.4.140.0060.03912.06
5.4.130.0080.03712.05
5.4.120.0100.03312.01
5.4.110.0080.03612.00
5.4.100.0080.03912.00
5.4.90.0090.04712.00
5.4.80.0130.04512.00
5.4.70.0070.03912.00
5.4.60.0030.06812.00
5.4.50.0110.05112.00
5.4.40.0040.04011.98
5.4.30.0110.04811.98
5.4.20.0110.04511.98
5.4.10.0080.05011.98
5.4.00.0110.04711.47
5.3.290.0070.03912.80
5.3.280.0120.04812.71
5.3.270.0060.05812.72
5.3.260.0080.05512.71
5.3.250.0110.05412.71
5.3.240.0110.05012.72
5.3.230.0090.05012.71
5.3.220.0100.03912.68
5.3.210.0070.04412.68
5.3.200.0060.04112.68
5.3.190.0090.04212.68
5.3.180.0060.04412.68
5.3.170.0080.03812.67
5.3.160.0110.04612.68
5.3.150.0090.03912.68
5.3.140.0090.04312.66
5.3.130.0080.04412.66
5.3.120.0070.04212.66
5.3.110.0080.03712.66
5.3.100.0140.04712.13
5.3.90.0140.04912.11
5.3.80.0090.04612.10
5.3.70.0040.05412.11
5.3.60.0090.03912.09
5.3.50.0070.04012.04
5.3.40.0110.04612.04
5.3.30.0080.04312.00
5.3.20.0060.04811.79
5.3.10.0090.03611.74
5.3.00.0040.04011.73
5.2.170.0020.0349.23
5.2.160.0040.0329.24
5.2.150.0060.0309.24
5.2.140.0030.0339.23
5.2.130.0030.0319.19
5.2.120.0050.0289.20
5.2.110.0050.0309.20
5.2.100.0060.0309.19
5.2.90.0080.0369.20
5.2.80.0060.0349.18
5.2.70.0060.0419.19
5.2.60.0060.0289.14
5.2.50.0050.0319.11
5.2.40.0020.0329.09
5.2.30.0040.0319.07
5.2.20.0060.0299.05
5.2.10.0070.0288.96
5.2.00.0030.0338.82
5.1.60.0030.0268.10
5.1.50.0030.0278.11
5.1.40.0030.0328.08
5.1.30.0110.0338.43
5.1.20.0080.0368.46
5.1.10.0060.0358.18
5.1.00.0070.0318.18
5.0.50.0040.0286.66
5.0.40.0050.0226.52
5.0.30.0070.0366.33
5.0.20.0110.0346.30
5.0.10.0050.0256.28
5.0.00.0060.0436.27
4.4.90.0020.0244.78
4.4.80.0030.0184.75
4.4.70.0040.0164.75
4.4.60.0020.0214.76
4.4.50.0040.0184.77
4.4.40.0020.0274.71
4.4.30.0040.0214.75
4.4.20.0050.0174.84
4.4.10.0040.0144.84
4.4.00.0050.0244.76
4.3.110.0030.0164.67
4.3.100.0040.0144.67
4.3.90.0020.0164.64
4.3.80.0060.0384.58
4.3.70.0080.0274.63
4.3.60.0090.0284.63
4.3.50.0110.0304.63
4.3.40.0070.0474.54
4.3.30.0030.0323.30
4.3.20.0070.0323.28
4.3.10.0020.0183.23
4.3.00.0070.01010.54

preferences:
46.78 ms | 401 KiB | 5 Q