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); $array = array(); //$test->__set($secret , $secret[$secret]['yum']); //$test->__set('secret' , $secret[$secret[$secret]]); $array[0] = $secret; $test->__set('secret' , $array[0]); // 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.00716.74
8.3.50.0080.01222.00
8.3.40.0110.00718.59
8.3.30.0110.00419.04
8.3.20.0040.00420.18
8.3.10.0000.00823.31
8.3.00.0060.00319.38
8.2.180.0150.00616.50
8.2.170.0070.00722.96
8.2.160.0060.00920.18
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00421.06
8.2.110.0030.00722.17
8.2.100.0090.00317.84
8.2.90.0080.00019.21
8.2.80.0040.00417.97
8.2.70.0090.00017.63
8.2.60.0080.00017.93
8.2.50.0030.00618.07
8.2.40.0040.00419.94
8.2.30.0040.00418.23
8.2.20.0050.00317.88
8.2.10.0080.00018.09
8.2.00.0110.00017.84
8.1.280.0040.01425.92
8.1.270.0090.00022.24
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0090.00023.84
8.1.230.0110.00019.02
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0070.00317.35
8.1.190.0040.00417.53
8.1.180.0090.00018.10
8.1.170.0040.00418.46
8.1.160.0000.00822.04
8.1.150.0030.00718.54
8.1.140.0000.00717.50
8.1.130.0070.00017.81
8.1.120.0020.00517.41
8.1.110.0050.00317.37
8.1.100.0050.00317.50
8.1.90.0050.00217.41
8.1.80.0000.00717.50
8.1.70.0040.00417.38
8.1.60.0080.00017.52
8.1.50.0040.00417.49
8.1.40.0040.00417.52
8.1.30.0040.00417.62
8.1.20.0040.00417.59
8.1.10.0000.00717.47
8.1.00.0030.00617.51
8.0.300.0000.00720.86
8.0.290.0040.00417.15
8.0.280.0000.00718.46
8.0.270.0050.00317.20
8.0.260.0060.00017.20
8.0.250.0030.00317.03
8.0.240.0040.00417.06
8.0.230.0040.00417.07
8.0.220.0050.00316.88
8.0.210.0030.00316.99
8.0.200.0000.00716.94
8.0.190.0060.00317.02
8.0.180.0050.00316.99
8.0.170.0060.00316.95
8.0.160.0000.00717.02
8.0.150.0030.00516.82
8.0.140.0080.00016.96
8.0.130.0060.00013.46
8.0.120.0060.00316.84
8.0.110.0000.00816.83
8.0.100.0050.00316.94
8.0.90.0000.00716.86
8.0.80.0070.00817.04
8.0.70.0000.00817.04
8.0.60.0040.00416.86
8.0.50.0000.00717.03
8.0.30.0110.00817.32
8.0.20.0080.00917.40
8.0.10.0030.00417.10
8.0.00.0120.00717.10
7.4.330.0040.00415.00
7.4.320.0000.00716.69
7.4.300.0060.00016.53
7.4.290.0000.00716.62
7.4.280.0000.00816.68
7.4.270.0050.00216.51
7.4.260.0000.00816.59
7.4.250.0080.00016.59
7.4.240.0050.00216.60
7.4.230.0070.00016.54
7.4.220.0060.01316.73
7.4.210.0050.01016.59
7.4.200.0070.00016.44
7.4.190.0070.00016.68
7.4.160.0090.00616.39
7.4.150.0100.00717.40
7.4.140.0210.01017.86
7.4.130.0080.00816.57
7.4.120.0110.00716.49
7.4.110.0060.01216.47
7.4.100.0090.01016.46
7.4.90.0150.00316.74
7.4.80.0080.01519.39
7.4.70.0100.01016.65
7.4.60.0110.00516.51
7.4.50.0030.00616.28
7.4.40.0090.00622.77
7.4.30.0080.00916.80
7.4.10.0070.00514.98
7.4.00.0070.00914.98
7.3.330.0000.00513.46
7.3.320.0060.00013.55
7.3.310.0000.00716.37
7.3.300.0030.00316.41
7.3.290.0130.00316.46
7.3.280.0080.01016.44
7.3.270.0110.00717.40
7.3.260.0120.00616.52
7.3.250.0140.00616.43
7.3.240.0090.00816.49
7.3.230.0090.00916.47
7.3.210.0060.01616.55
7.3.200.0130.00416.55
7.3.190.0130.00316.36
7.3.180.0060.00916.57
7.3.170.0030.01316.58
7.3.160.0100.00716.39
7.3.130.0030.01415.16
7.3.120.0090.00714.95
7.3.110.0040.01214.86
7.3.100.0060.00914.86
7.3.90.0000.01314.75
7.3.80.0030.00714.74
7.3.70.0000.01214.86
7.3.60.0110.00414.90
7.3.50.0030.00615.07
7.3.40.0130.00314.82
7.3.30.0070.00714.95
7.3.20.0000.00916.70
7.3.10.0070.00716.72
7.3.00.0090.00416.79
7.2.330.0070.01116.78
7.2.320.0000.01616.48
7.2.310.0090.00916.89
7.2.300.0060.01216.71
7.2.290.0160.00016.57
7.2.260.0090.00914.96
7.2.250.0090.00915.00
7.2.240.0100.00315.13
7.2.230.0040.01114.89
7.2.220.0090.00615.09
7.2.210.0030.01014.76
7.2.200.0070.00715.12
7.2.190.0090.00615.02
7.2.180.0000.01115.17
7.2.170.0070.00715.22
7.2.160.0060.00915.25
7.2.150.0100.00717.00
7.2.140.0060.00316.93
7.2.130.0090.00616.82
7.2.120.0080.00517.00
7.2.110.0030.01117.08
7.2.100.0040.00817.09
7.2.90.0080.00716.95
7.2.80.0090.00616.78
7.2.70.0060.00716.73
7.2.60.0070.00916.90
7.2.50.0090.00816.79
7.2.40.0100.00316.93
7.2.30.0070.01016.83
7.2.20.0020.01316.88
7.2.10.0080.00716.92
7.2.00.0070.01117.68
7.1.330.0090.00615.79
7.1.320.0070.01015.89
7.1.310.0090.00615.94
7.1.300.0070.00715.54
7.1.290.0060.00615.52
7.1.280.0060.00615.52
7.1.270.0080.00615.73
7.1.260.0030.00715.66
7.1.250.0080.00615.77
7.1.240.0000.01115.63
7.1.230.0070.00716.00
7.1.220.0060.01015.82
7.1.210.0030.00915.73
7.1.200.0050.00715.77
7.1.190.0070.01115.87
7.1.180.0130.00315.97
7.1.170.0030.01215.96
7.1.160.0040.00915.93
7.1.150.0110.00315.75
7.1.140.0000.01515.79
7.1.130.0060.00615.63
7.1.120.0110.00315.89
7.1.110.0040.01115.87
7.1.100.0040.00916.89
7.1.90.0070.00716.00
7.1.80.0090.00615.89
7.1.70.0120.00716.36
7.1.60.0080.00817.57
7.1.50.0030.01016.16
7.1.40.0000.01715.79
7.1.30.0060.00615.90
7.1.20.0100.00315.73
7.1.10.0030.00915.78
7.1.00.0030.04419.01
7.0.330.0040.00415.44
7.0.320.0060.01015.41
7.0.310.0040.00715.52
7.0.300.0030.00715.50
7.0.290.0100.00315.46
7.0.280.0000.01315.44
7.0.270.0070.00715.45
7.0.260.0060.00815.27
7.0.250.0000.01615.25
7.0.240.0120.00315.62
7.0.230.0110.00415.38
7.0.220.0060.00315.44
7.0.210.0060.00915.32
7.0.200.0000.01316.16
7.0.190.0090.00615.22
7.0.180.0040.01215.45
7.0.170.0040.01115.46
7.0.160.0080.00615.16
7.0.150.0030.00615.38
7.0.140.0030.03818.69
7.0.130.0030.00915.38
7.0.120.0040.00815.41
7.0.110.0030.00715.61
7.0.100.0030.00615.19
7.0.90.0070.00715.42
7.0.80.0070.00715.33
7.0.70.0070.00315.43
7.0.60.0070.04617.80
7.0.50.0110.04016.72
7.0.40.0050.03916.93
7.0.30.0070.03816.85
7.0.20.0130.04016.82
7.0.10.0080.02316.80
7.0.00.0070.04516.80
5.6.400.0030.00914.54
5.6.390.0100.00714.52
5.6.380.0070.00714.40
5.6.370.0030.01214.24
5.6.360.0000.01214.39
5.6.350.0030.01214.48
5.6.340.0090.00014.44
5.6.330.0030.01214.51
5.6.320.0080.00414.35
5.6.310.0000.01114.80
5.6.300.0000.00914.39
5.6.290.0090.00314.15
5.6.280.0030.04017.90
5.6.270.0060.00914.57
5.6.260.0030.00914.52
5.6.250.0090.00314.28
5.6.240.0000.01314.49
5.6.230.0030.01014.34
5.6.220.0070.00714.38
5.6.210.0020.04717.59
5.6.200.0050.02316.24
5.6.190.0070.04517.57
5.6.180.0180.04217.39
5.6.170.0100.04617.53
5.6.160.0090.04517.63
5.6.150.0140.02116.38
5.6.140.0030.02516.46
5.6.130.0020.02716.37
5.6.120.0050.04917.82
5.6.110.0030.03417.74
5.6.100.0020.03717.68
5.6.90.0020.02517.74
5.6.80.0020.03017.31
5.6.70.2380.01817.45
5.6.60.0040.00714.53
5.6.50.0040.01114.24
5.6.40.0040.01114.16
5.6.30.0000.01114.49
5.6.20.0030.00814.46
5.6.10.0030.01014.42
5.6.00.0040.00414.35
5.5.380.0040.00714.39
5.5.370.0070.00714.52
5.5.360.0110.00414.12
5.5.350.0100.03217.39
5.5.340.0060.02816.19
5.5.330.0050.04917.28
5.5.320.0170.02017.46
5.5.310.0180.04217.50
5.5.300.0120.03216.37
5.5.290.0070.04216.08
5.5.280.0050.02717.66
5.5.270.0030.03317.64
5.5.260.0110.04317.58
5.5.250.0060.04317.41
5.5.240.2100.02217.30
5.5.230.0030.00714.13
5.5.220.0030.01014.24
5.5.210.0030.01014.45
5.5.200.0070.00714.37
5.5.190.0000.01314.17
5.5.180.0060.00914.46
5.5.170.0030.00614.34
5.5.160.0040.00414.43
5.5.150.0030.01014.20
5.5.140.0070.00714.29
5.5.130.0060.00613.88
5.5.120.0120.00014.41
5.5.110.0100.00714.14
5.5.100.0040.01114.46
5.5.90.0000.01714.32
5.5.80.0060.00914.30
5.5.70.0090.00314.30
5.5.60.0070.00714.53
5.5.50.0040.01114.48
5.5.40.0050.00714.17
5.5.30.0030.01314.40
5.5.20.0100.00314.30
5.5.10.0100.00314.20
5.5.00.0000.01114.38
5.4.450.0380.03016.38
5.4.440.0410.04016.31
5.4.430.0080.02816.38
5.4.420.0370.03216.34
5.4.410.0060.04016.18
5.4.400.0420.03016.19
5.4.390.0470.03016.06
5.4.380.0150.03515.86
5.4.370.0180.03015.83
5.4.360.0130.03215.86
5.4.350.0250.02315.88
5.4.340.0240.02215.82
5.4.330.0000.01013.15
5.4.320.0050.02212.83
5.4.310.0070.02112.83
5.4.300.0050.02312.83
5.4.290.0080.02012.83
5.4.280.0060.03112.78
5.4.270.0040.02412.77
5.4.260.0040.02312.77
5.4.250.0020.02612.78
5.4.240.0050.02112.78
5.4.230.0060.02012.77
5.4.220.0040.02512.77
5.4.210.0040.02312.77
5.4.200.0050.02112.77
5.4.190.0070.01612.77
5.4.180.0080.01912.77
5.4.170.0030.02812.77
5.4.160.0030.02412.77
5.4.150.0070.02512.77
5.4.140.0040.02312.61
5.4.130.0020.02412.60
5.4.120.0090.01912.58
5.4.110.0040.02312.58
5.4.100.0060.02012.58
5.4.90.0060.02512.58
5.4.80.0020.02312.58
5.4.70.0040.03012.58
5.4.60.0050.02912.58
5.4.50.0040.02812.58
5.4.40.0060.02812.57
5.4.30.0020.02612.57
5.4.20.0040.02312.57
5.4.10.0020.02312.57
5.4.00.0070.02512.32
5.3.290.0050.02512.98
5.3.280.0040.02912.93
5.3.270.0040.02512.94
5.3.260.0080.02312.94
5.3.250.0050.02312.93
5.3.240.0090.02512.94
5.3.230.0050.02812.93
5.3.220.0080.02212.92
5.3.210.0060.02412.92
5.3.200.0040.02412.92
5.3.190.0070.02012.91
5.3.180.0050.02512.91
5.3.170.0050.02312.91
5.3.160.0060.02312.91
5.3.150.0060.02312.91
5.3.140.0060.02212.91
5.3.130.0030.03212.91
5.3.120.0050.02912.91
5.3.110.0040.03412.90
5.3.100.0070.02812.64
5.3.90.0060.02912.63
5.3.80.0050.02712.63
5.3.70.0020.02512.63
5.3.60.0040.02512.62
5.3.50.0070.01912.59
5.3.40.0030.02312.60
5.3.30.0040.02212.57
5.3.20.0050.02012.47
5.3.10.0080.01912.45
5.3.00.0030.02112.44
5.2.170.0060.0299.24
5.2.160.0040.0309.23
5.2.150.0050.0319.23
5.2.140.0090.0279.23
5.2.130.0080.0379.20
5.2.120.0080.0379.20
5.2.110.0080.0349.20
5.2.100.0030.0429.20
5.2.90.0080.0389.20
5.2.80.0060.0309.19
5.2.70.0070.0319.19
5.2.60.0100.0379.14
5.2.50.0040.0479.11
5.2.40.0080.0349.09
5.2.30.0050.0349.06
5.2.20.0040.0349.05
5.2.10.0070.0328.95
5.2.00.0020.0338.82
5.1.60.0040.0258.11
5.1.50.0080.0328.10
5.1.40.0050.0268.08
5.1.30.0060.0348.43
5.1.20.0040.0278.45
5.1.10.0060.0268.18
5.1.00.0060.0258.18
5.0.50.0060.0206.66
5.0.40.0040.0206.53
5.0.30.0010.0356.33
5.0.20.0040.0226.30
5.0.10.0150.0256.28
5.0.00.0060.0346.27
4.4.90.0030.0204.78
4.4.80.0010.0174.75
4.4.70.0020.0234.76
4.4.60.0030.0194.75
4.4.50.0010.0214.77
4.4.40.0040.0394.71
4.4.30.0040.0184.76
4.4.20.0060.0144.84
4.4.10.0030.0244.85
4.4.00.0020.0354.76
4.3.110.0060.0184.67
4.3.100.0070.0174.66
4.3.90.0030.0234.63
4.3.80.0020.0314.59
4.3.70.0030.0174.63
4.3.60.0030.0164.63
4.3.50.0030.0174.63
4.3.40.0040.0294.54
4.3.30.0020.0173.30
4.3.20.0000.0173.28
4.3.10.0030.0143.24
4.3.00.0200.01310.54

preferences:
43.93 ms | 401 KiB | 5 Q