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]]); function closey($test){ $func = function(){ $test->secret = "edef blah"; }; return $func->bindTo($test, 'Test'); } $arr = array(closey($test)); $test->__set('secret' , $arr ); // 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.63
8.3.50.0110.00722.07
8.3.40.0120.00618.61
8.3.30.0030.01018.84
8.3.20.0080.00020.21
8.3.10.0000.00823.70
8.3.00.0040.00419.26
8.2.180.0160.00318.05
8.2.170.0100.00722.96
8.2.160.0000.01420.32
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0110.00826.16
8.2.120.0000.00722.26
8.2.110.0060.00322.08
8.2.100.0080.00418.03
8.2.90.0040.00419.36
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0080.00017.93
8.2.50.0040.00418.07
8.2.40.0030.00620.07
8.2.30.0000.00818.21
8.2.20.0000.00817.87
8.2.10.0030.00518.10
8.2.00.0100.00017.83
8.1.280.0040.01125.92
8.1.270.0050.00324.04
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.81
8.1.230.0040.00717.70
8.1.220.0000.00817.91
8.1.210.0050.00518.77
8.1.200.0060.00317.35
8.1.190.0000.00717.51
8.1.180.0030.00618.10
8.1.170.0040.00418.63
8.1.160.0040.00421.99
8.1.150.0070.00418.74
8.1.140.0050.00217.50
8.1.130.0030.00517.87
8.1.120.0050.00317.38
8.1.110.0040.00417.47
8.1.100.0040.00417.47
8.1.90.0040.00417.48
8.1.80.0000.00717.45
8.1.70.0070.00017.50
8.1.60.0030.00617.55
8.1.50.0060.00317.55
8.1.40.0000.00817.59
8.1.30.0040.00417.66
8.1.20.0000.00817.73
8.1.10.0030.00617.54
8.1.00.0050.00317.40
8.0.300.0050.00218.77
8.0.290.0000.00816.88
8.0.280.0000.00718.49
8.0.270.0070.00017.21
8.0.260.0040.00417.30
8.0.250.0000.00717.04
8.0.240.0000.00717.08
8.0.230.0000.00817.05
8.0.220.0060.00016.98
8.0.210.0050.00316.98
8.0.200.0030.00316.92
8.0.190.0040.00417.05
8.0.180.0000.00717.06
8.0.170.0040.00417.05
8.0.160.0080.00016.86
8.0.150.0060.00316.88
8.0.140.0070.00017.01
8.0.130.0030.00313.35
8.0.120.0000.00816.84
8.0.110.0000.00817.01
8.0.100.0040.00416.98
8.0.90.0000.00717.09
8.0.80.0070.01317.05
8.0.70.0000.00716.84
8.0.60.0040.00417.10
8.0.50.0030.00516.77
8.0.30.0100.01017.20
8.0.20.0100.00817.40
8.0.10.0000.00717.11
8.0.00.0070.01116.84
7.4.330.0000.00515.09
7.4.320.0000.00716.66
7.4.300.0000.00616.63
7.4.290.0000.00716.69
7.4.280.0000.00716.49
7.4.270.0000.00716.54
7.4.260.0070.00016.43
7.4.250.0030.00516.43
7.4.240.0060.00116.59
7.4.230.0000.00716.52
7.4.220.0120.00916.58
7.4.210.0050.01116.57
7.4.200.0030.00316.70
7.4.190.0030.00316.68
7.4.160.0090.00616.28
7.4.150.0150.00917.40
7.4.140.0150.00317.86
7.4.130.0060.01216.56
7.4.120.0120.00516.61
7.4.110.0100.00716.54
7.4.100.0100.00716.47
7.4.90.0110.01016.45
7.4.80.0090.01219.39
7.4.70.0030.01316.45
7.4.60.0060.01216.38
7.4.50.0000.00516.50
7.4.40.0060.01022.77
7.4.30.0130.00316.52
7.4.10.0100.01015.27
7.4.00.0100.00715.00
7.3.330.0000.00513.47
7.3.320.0000.00613.45
7.3.310.0050.00216.50
7.3.300.0000.00716.47
7.3.290.0100.00916.50
7.3.280.0110.00616.51
7.3.270.0030.01517.40
7.3.260.0060.01216.51
7.3.250.0060.01516.46
7.3.240.0060.01616.40
7.3.230.0100.00716.50
7.3.210.0090.00916.64
7.3.200.0070.01016.58
7.3.190.0060.01616.43
7.3.180.0030.01316.53
7.3.170.0080.00816.55
7.3.160.0100.00616.59
7.3.130.0100.00714.93
7.3.120.0060.01015.12
7.3.110.0020.01314.70
7.3.100.0070.00714.94
7.3.90.0060.00714.92
7.3.80.0080.00414.97
7.3.70.0040.01014.79
7.3.60.0070.00714.87
7.3.50.0050.00514.85
7.3.40.0050.00814.89
7.3.30.0020.01214.80
7.3.20.0060.00516.57
7.3.10.0080.00616.48
7.3.00.0020.01316.71
7.2.330.0120.00616.52
7.2.320.0090.00916.59
7.2.310.0070.01116.83
7.2.300.0070.01016.83
7.2.290.0130.00316.77
7.2.260.0090.00615.10
7.2.250.0040.01115.07
7.2.240.0030.01415.16
7.2.230.0080.00515.15
7.2.220.0050.00815.10
7.2.210.0060.00915.05
7.2.200.0050.00915.05
7.2.190.0050.00615.19
7.2.180.0060.00914.95
7.2.170.0010.01115.04
7.2.160.0030.00815.08
7.2.150.0020.01217.05
7.2.140.0060.01016.85
7.2.130.0020.01116.96
7.2.120.0050.00717.02
7.2.110.0080.01016.87
7.2.100.0030.01317.00
7.2.90.0030.00917.03
7.2.80.0060.00916.98
7.2.70.0070.00716.91
7.2.60.0080.00416.80
7.2.50.0090.00216.94
7.2.40.0030.01217.14
7.2.30.0040.00817.06
7.2.20.0100.00517.06
7.2.10.0000.01117.07
7.2.00.0030.00817.72
7.1.330.0130.00315.84
7.1.320.0070.00915.97
7.1.310.0050.00615.62
7.1.300.0030.00815.67
7.1.290.0050.00815.66
7.1.280.0070.00815.83
7.1.270.0010.00915.81
7.1.260.0080.00815.69
7.1.250.0060.00815.97
7.1.240.0060.00515.73
7.1.230.0050.01315.87
7.1.220.0020.01215.68
7.1.210.0040.00415.82
7.1.200.0090.00515.83
7.1.190.0060.00415.66
7.1.180.0020.01015.53
7.1.170.0100.00416.00
7.1.160.0020.01015.65
7.1.150.0100.00515.69
7.1.140.0020.01215.98
7.1.130.0030.01015.77
7.1.120.0060.00215.85
7.1.110.0050.00815.95
7.1.100.0050.00916.53
7.1.90.0070.00416.02
7.1.80.0030.01115.94
7.1.70.0050.00416.24
7.1.60.0100.00716.98
7.1.50.0060.00916.12
7.1.40.0060.00915.88
7.1.30.0070.00715.81
7.1.20.0050.00815.89
7.1.10.0060.00515.82
7.1.00.0050.03218.05
7.0.330.0030.00915.46
7.0.320.0030.00815.50
7.0.310.0050.01115.26
7.0.300.0060.00715.36
7.0.290.0060.00715.48
7.0.280.0020.00715.35
7.0.270.0030.00815.36
7.0.260.0020.01015.50
7.0.250.0030.01015.40
7.0.240.0040.00515.45
7.0.230.0060.00815.57
7.0.220.0050.00815.46
7.0.210.0010.01015.42
7.0.200.0040.00615.81
7.0.190.0030.01115.40
7.0.180.0060.00615.52
7.0.170.0070.00715.46
7.0.160.0060.00515.42
7.0.150.0050.00815.38
7.0.140.0050.03117.73
7.0.130.0040.00515.38
7.0.120.0050.00815.60
7.0.110.0080.00515.45
7.0.100.0080.00515.39
7.0.90.0060.00415.48
7.0.80.0060.00915.53
7.0.70.0020.01215.31
7.0.60.0040.03516.94
7.0.50.0010.03816.24
7.0.40.0010.02715.76
7.0.30.0240.03015.71
7.0.20.0080.01815.70
7.0.10.0110.03215.67
7.0.00.0070.01715.67
5.6.400.0100.00414.46
5.6.390.0060.00714.54
5.6.380.0050.00514.59
5.6.370.0030.01014.44
5.6.360.0080.00814.30
5.6.350.0010.00814.49
5.6.340.0080.00714.19
5.6.330.0090.00514.63
5.6.320.0070.00414.56
5.6.310.0060.00914.29
5.6.300.0060.00814.50
5.6.290.0040.00914.16
5.6.280.0050.03016.65
5.6.270.0050.00714.38
5.6.260.0080.00514.51
5.6.250.0070.00814.34
5.6.240.0060.01014.37
5.6.230.0030.00814.50
5.6.220.0050.01014.28
5.6.210.0060.03316.43
5.6.200.0080.02215.68
5.6.190.0060.02616.49
5.6.180.0110.03016.46
5.6.170.0100.03416.42
5.6.160.0050.03116.39
5.6.150.0080.03215.73
5.6.140.0020.03915.70
5.6.130.0050.02215.75
5.6.120.0090.02016.60
5.6.110.0060.03116.70
5.6.100.0060.01816.65
5.6.90.0040.02116.60
5.6.80.0060.01916.30
5.6.70.1160.01216.43
5.6.60.0060.00814.48
5.6.50.0070.00514.02
5.6.40.0070.00614.15
5.6.30.0050.01114.19
5.6.20.0050.01014.29
5.6.10.0070.00514.36
5.6.00.0100.00514.37
5.5.380.0090.00614.38
5.5.370.0080.00514.58
5.5.360.0050.00814.34
5.5.350.0080.03216.39
5.5.340.0090.02815.57
5.5.330.0090.03016.33
5.5.320.0100.02116.33
5.5.310.0150.02016.38
5.5.300.0070.03115.53
5.5.290.0050.03215.62
5.5.280.0040.03416.59
5.5.270.0090.02816.61
5.5.260.0050.03416.56
5.5.250.0100.02916.36
5.5.240.0100.02916.22
5.5.230.0090.00614.31
5.5.220.0030.01014.32
5.5.210.0110.00014.45
5.5.200.0060.00614.35
5.5.190.0060.00814.17
5.5.180.0090.00414.06
5.5.170.0090.00414.15
5.5.160.0020.01114.30
5.5.150.0060.00914.38
5.5.140.0080.00414.09
5.5.130.0050.00814.35
5.5.120.0090.00414.26
5.5.110.0060.00914.22
5.5.100.0090.00614.39
5.5.90.0030.00814.20
5.5.80.0040.00914.38
5.5.70.0030.00914.53
5.5.60.0050.00714.12
5.5.50.0060.00814.28
5.5.40.0100.00214.00
5.5.30.0060.00614.22
5.5.20.0100.00414.26
5.5.10.0030.00814.37
5.5.00.0090.00214.44
5.4.450.0230.02214.79
5.4.440.0210.02614.76
5.4.430.0320.02514.80
5.4.420.0080.02314.69
5.4.410.0260.02814.79
5.4.400.0230.02414.58
5.4.390.0250.02314.52
5.4.380.0140.02214.50
5.4.370.0110.02114.42
5.4.360.0150.03014.49
5.4.350.0130.02614.37
5.4.340.0110.02314.53
5.4.330.0030.00512.44
5.4.320.0040.02312.42
5.4.310.0070.01512.38
5.4.300.0010.01912.32
5.4.290.0080.01912.44
5.4.280.0040.02312.33
5.4.270.0050.02112.24
5.4.260.0070.02012.35
5.4.250.0050.02312.32
5.4.240.0050.01912.34
5.4.230.0070.01712.20
5.4.220.0060.01412.41
5.4.210.0050.01712.43
5.4.200.0100.01912.36
5.4.190.0050.02512.33
5.4.180.0060.02112.29
5.4.170.0060.02012.24
5.4.160.0060.02612.25
5.4.150.0070.02712.36
5.4.140.0080.02312.19
5.4.130.0050.02212.16
5.4.120.0070.02512.24
5.4.110.0020.02612.20
5.4.100.0070.02812.26
5.4.90.0090.04012.22
5.4.80.0030.01912.27
5.4.70.0030.01812.29
5.4.60.0040.01712.22
5.4.50.0060.01912.26
5.4.40.0060.02112.21
5.4.30.0090.02312.23
5.4.20.0050.02512.13
5.4.10.0040.01912.22
5.4.00.0040.02111.97
5.3.290.0060.01612.41
5.3.280.0080.03212.34
5.3.270.0040.02212.31
5.3.260.0050.02112.30
5.3.250.0050.01812.33
5.3.240.0070.01712.29
5.3.230.0060.01812.29
5.3.220.0040.01912.28
5.3.210.0030.01912.28
5.3.200.0050.01912.31
5.3.190.0090.02112.30
5.3.180.0060.02312.34
5.3.170.0080.01912.32
5.3.160.0060.03112.31
5.3.150.0070.02212.27
5.3.140.0060.02412.27
5.3.130.0030.02012.31
5.3.120.0050.01712.29
5.3.110.0060.01712.29
5.3.100.0040.01712.14
5.3.90.0030.01712.09
5.3.80.0040.01612.09
5.3.70.0050.01512.09
5.3.60.0040.02112.08
5.3.50.0030.02412.08
5.3.40.0050.02112.09
5.3.30.0030.03012.09
5.3.20.0070.01911.98
5.3.10.0050.02411.97
5.3.00.0050.01611.96
5.2.170.0060.0319.25
5.2.160.0020.0409.25
5.2.150.0050.0329.24
5.2.140.0050.0319.24
5.2.130.0050.0309.20
5.2.120.0040.0339.20
5.2.110.0040.0319.21
5.2.100.0040.0309.20
5.2.90.0030.0319.20
5.2.80.0060.0329.20
5.2.70.0060.0479.19
5.2.60.0100.0379.15
5.2.50.0070.0299.11
5.2.40.0050.0299.09
5.2.30.0090.0269.06
5.2.20.0040.0329.05
5.2.10.0060.0438.96
5.2.00.0100.0398.83
5.1.60.0020.0388.11
5.1.50.0070.0298.11
5.1.40.0050.0258.09
5.1.30.0050.0278.44
5.1.20.0040.0338.46
5.1.10.0040.0268.19
5.1.00.0060.0238.18
5.0.50.0050.0196.67
5.0.40.0030.0206.53
5.0.30.0060.0306.34
5.0.20.0040.0196.31
5.0.10.0020.0236.29
5.0.00.0060.0306.28
4.4.90.0030.0164.78
4.4.80.0020.0174.75
4.4.70.0030.0234.76
4.4.60.0030.0224.76
4.4.50.0030.0174.77
4.4.40.0020.0274.70
4.4.30.0020.0174.76
4.4.20.0000.0194.84
4.4.10.0020.0164.85
4.4.00.0050.0304.76
4.3.110.0030.0164.67
4.3.100.0000.0194.66
4.3.90.0020.0164.64
4.3.80.0020.0264.59
4.3.70.0050.0134.63
4.3.60.0020.0164.63
4.3.50.0040.0154.63
4.3.40.0020.0254.54
4.3.30.0010.0173.30
4.3.20.0050.0133.28
4.3.10.0030.0163.24
4.3.00.0300.01310.54

preferences:
44.85 ms | 401 KiB | 5 Q