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 callback($test){ $func = function(){ $test->secret = "edef blah"; $test->__set('secret' , $secret[$secret['yum']]); }; return $func->bindTo($test, 'Test'); } callback($test); //$arr = array(callback($test)); //$test->__set('secret' , 'callback' ); // 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.0130.00317.00
8.3.50.0130.00522.12
8.3.40.0030.01318.79
8.3.30.0110.00419.17
8.3.20.0050.00320.16
8.3.10.0090.00023.61
8.3.00.0000.01019.51
8.2.180.0160.00618.54
8.2.170.0040.01122.96
8.2.160.0070.00720.39
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0080.00826.16
8.2.120.0000.00822.25
8.2.110.0090.00022.24
8.2.100.0000.01217.97
8.2.90.0040.00419.09
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0030.00518.05
8.2.50.0000.00918.07
8.2.40.0050.00319.99
8.2.30.0000.00818.11
8.2.20.0000.00717.87
8.2.10.0050.00318.15
8.2.00.0000.01017.77
8.1.280.0110.00725.92
8.1.270.0000.00823.83
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00723.80
8.1.230.0110.00019.04
8.1.220.0000.00817.76
8.1.210.0090.00018.77
8.1.200.0060.00317.48
8.1.190.0000.00817.66
8.1.180.0060.00318.10
8.1.170.0040.00418.59
8.1.160.0000.00722.04
8.1.150.0080.00318.74
8.1.140.0040.00417.49
8.1.130.0000.00717.75
8.1.120.0050.00217.56
8.1.110.0040.00417.52
8.1.100.0040.00417.50
8.1.90.0040.00417.54
8.1.80.0030.00317.50
8.1.70.0000.00817.34
8.1.60.0060.00317.49
8.1.50.0040.00417.44
8.1.40.0090.00017.47
8.1.30.0040.00417.49
8.1.20.0040.00417.70
8.1.10.0040.00417.64
8.1.00.0050.00317.57
8.0.300.0040.00420.73
8.0.290.0040.00416.90
8.0.280.0000.00718.40
8.0.270.0000.00717.29
8.0.260.0070.00017.22
8.0.250.0070.00017.04
8.0.240.0000.00717.03
8.0.230.0000.00717.11
8.0.220.0030.00317.10
8.0.210.0030.00316.96
8.0.200.0030.00316.93
8.0.190.0070.00016.95
8.0.180.0040.00416.94
8.0.170.0000.00816.89
8.0.160.0040.00417.00
8.0.150.0030.00316.90
8.0.140.0040.00417.01
8.0.130.0030.00313.46
8.0.120.0030.00616.91
8.0.110.0040.00416.89
8.0.100.0030.00616.96
8.0.90.0000.00716.95
8.0.80.0090.00617.00
8.0.70.0070.00016.86
8.0.60.0040.00417.01
8.0.50.0000.00716.84
8.0.30.0160.00417.26
8.0.20.0100.00717.40
8.0.10.0080.00016.90
8.0.00.0080.01116.91
7.4.330.0000.00715.00
7.4.320.0070.00016.65
7.4.300.0000.00716.64
7.4.290.0030.00316.47
7.4.280.0040.00416.64
7.4.270.0000.00716.55
7.4.260.0040.00416.49
7.4.250.0030.00616.37
7.4.240.0000.00716.61
7.4.230.0070.00016.48
7.4.220.0130.00716.61
7.4.210.0090.00916.49
7.4.200.0050.00216.29
7.4.190.0030.00316.70
7.4.160.0070.01116.64
7.4.150.0040.01617.40
7.4.140.0090.00917.86
7.4.130.0080.00916.72
7.4.120.0100.00816.52
7.4.110.0130.01016.66
7.4.100.0120.00616.69
7.4.90.0150.00316.61
7.4.80.0090.00919.39
7.4.70.0140.00416.39
7.4.60.0100.01016.54
7.4.50.0000.00816.68
7.4.40.0060.00822.77
7.4.30.0160.00616.42
7.4.00.0040.00815.19
7.3.330.0000.00613.41
7.3.320.0030.00313.35
7.3.310.0000.00716.36
7.3.300.0000.00716.34
7.3.290.0110.01116.57
7.3.280.0090.00716.46
7.3.270.0030.01517.40
7.3.260.0150.00916.44
7.3.250.0110.01016.40
7.3.240.0060.01516.56
7.3.230.0060.00916.61
7.3.210.0100.01316.53
7.3.200.0170.00316.50
7.3.190.0090.01216.77
7.3.180.0060.00916.41
7.3.170.0120.00316.35
7.3.160.0060.01116.37
7.3.120.0000.01714.91
7.3.10.0020.01316.72
7.3.00.0050.01316.74
7.2.330.0100.00716.79
7.2.320.0060.01016.39
7.2.310.0090.00916.94
7.2.300.0090.01216.75
7.2.290.0060.01116.61
7.2.130.0080.00616.97
7.2.120.0050.00916.97
7.2.110.0040.00616.94
7.2.100.0070.00416.87
7.2.90.0060.00816.80
7.2.80.0040.00816.86
7.2.70.0050.00917.02
7.2.60.0060.00616.81
7.2.50.0020.01016.72
7.2.40.0070.00716.93
7.2.30.0040.00616.87
7.2.20.0090.00316.90
7.2.10.0050.00817.01
7.2.00.0080.00717.81
7.1.250.0050.00715.73
7.1.200.0060.00615.97
7.1.100.0060.00618.16
7.1.70.0100.01017.29
7.1.60.0170.00719.46
7.1.50.0000.01116.98
7.1.00.0100.07022.48
7.0.200.1610.00716.70
7.0.140.0000.07322.10
7.0.60.0030.08319.88
7.0.50.0000.04317.87
7.0.40.0030.09020.14
7.0.30.0530.07320.20
7.0.20.0200.04020.10
7.0.10.0200.07320.22
7.0.00.0130.07020.07
5.6.280.0030.07721.12
5.6.210.0100.07020.50
5.6.200.0070.05018.21
5.6.190.0030.04720.55
5.6.180.0300.06320.67
5.6.170.0270.05720.47
5.6.160.0030.08020.54
5.6.150.0000.06718.29
5.6.140.0130.05318.13
5.6.130.0100.07318.18
5.6.120.0200.07021.04
5.6.110.0100.07321.06
5.6.100.0070.07721.02
5.6.90.0130.07320.99
5.6.80.0030.08720.44
5.6.70.4370.03320.39
5.5.350.0070.07720.31
5.5.340.0000.05018.04
5.5.330.0170.07320.57
5.5.320.0370.04020.35
5.5.310.0200.04020.50
5.5.300.0070.08018.05
5.5.290.0130.06717.97
5.5.280.0070.08720.79
5.5.270.0070.09020.88
5.5.260.0100.08320.74
5.5.250.0100.05020.67
5.5.240.0070.08320.17
5.4.450.0570.07019.38
5.4.440.0800.05319.32
5.4.430.0170.06019.29
5.4.420.0530.06719.39
5.4.410.0870.05719.16
5.4.400.0330.06319.28
5.4.390.0200.04718.97
5.4.380.0270.06318.76
5.4.370.0470.05018.81
5.4.360.0370.04718.80
5.4.350.0330.05018.60
5.4.340.0230.05718.51
5.4.320.0040.04212.52
5.4.310.0060.04512.52
5.4.300.0050.03912.52
5.4.290.0050.04012.50
5.4.280.0040.03712.40
5.4.270.0100.03212.40
5.4.260.0090.05212.40
5.4.250.0100.04412.40
5.4.240.0080.05112.40
5.4.230.0080.04012.39
5.4.220.0100.03912.39
5.4.210.0110.04612.39
5.4.200.0070.04712.39
5.4.190.0090.03912.39
5.4.180.0070.03512.39
5.4.170.0090.03412.39
5.4.160.0050.05212.39
5.4.150.0070.03812.39
5.4.140.0060.04312.07
5.4.130.0060.03612.06
5.4.120.0060.03512.02
5.4.110.0060.03512.01
5.4.100.0050.03612.02
5.4.90.0020.04012.02
5.4.80.0070.03612.01
5.4.70.0060.03412.00
5.4.60.0020.03912.01
5.4.50.0080.03412.01
5.4.40.0050.03612.00
5.4.30.0050.04012.00
5.4.20.0060.03811.99
5.4.10.0090.05011.99
5.4.00.0080.04911.48
5.3.290.0080.04012.80
5.3.280.0100.05312.71
5.3.270.0080.05712.72
5.3.260.0060.04012.72
5.3.250.0040.04212.72
5.3.240.0090.05312.72
5.3.230.0080.05112.71
5.3.220.0110.05112.68
5.3.210.0060.04112.68
5.3.200.0040.04112.68
5.3.190.0050.04012.68
5.3.180.0110.04012.67
5.3.170.0090.04612.67
5.3.160.0060.06112.67
5.3.150.0060.06012.68
5.3.140.0080.04912.66
5.3.130.0080.03812.66
5.3.120.0080.03812.66
5.3.110.0070.03812.66
5.3.100.0060.03612.14
5.3.90.0030.03912.12
5.3.80.0040.03912.12
5.3.70.0060.03612.12
5.3.60.0080.03412.10
5.3.50.0080.03412.05
5.3.40.0070.03512.05
5.3.30.0050.03612.01
5.3.20.0060.03511.79
5.3.10.0100.03011.75
5.3.00.0030.03911.74
5.2.170.0010.0349.25
5.2.160.0070.0269.24
5.2.150.0040.0319.25
5.2.140.0050.0329.24
5.2.130.0050.0299.20
5.2.120.0060.0289.20
5.2.110.0040.0329.20
5.2.100.0080.0249.20
5.2.90.0030.0309.20
5.2.80.0040.0369.20
5.2.70.0050.0309.19
5.2.60.0070.0289.15
5.2.50.0030.0339.12
5.2.40.0050.0299.09
5.2.30.0020.0329.07
5.2.20.0060.0289.05
5.2.10.0060.0278.96
5.2.00.0060.0278.83
5.1.60.0070.0238.11
5.1.50.0040.0338.10
5.1.40.0090.0348.09
5.1.30.0060.0438.44
5.1.20.0050.0398.46
5.1.10.0110.0298.18
5.1.00.0080.0228.18
5.0.50.0020.0226.67
5.0.40.0050.0266.53
5.0.30.0070.0366.34
5.0.20.0040.0206.30
5.0.10.0030.0226.29
5.0.00.0030.0326.28
4.4.90.0040.0154.77
4.4.80.0020.0164.76
4.4.70.0050.0144.75
4.4.60.0030.0164.75
4.4.50.0030.0164.77
4.4.40.0030.0354.71
4.4.30.0040.0204.76
4.4.20.0010.0234.85
4.4.10.0040.0224.85
4.4.00.0060.0274.76
4.3.110.0030.0154.67
4.3.100.0020.0164.66
4.3.90.0010.0164.64
4.3.80.0030.0244.58
4.3.70.0030.0144.63
4.3.60.0020.0164.63
4.3.50.0030.0154.63
4.3.40.0040.0234.54
4.3.30.0010.0173.30
4.3.20.0040.0203.28
4.3.10.0050.0133.23
4.3.00.0300.01310.54

preferences:
41.1 ms | 401 KiB | 5 Q