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"; }; return $func->bindTo($test, '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.0100.00316.75
8.3.50.0100.00721.95
8.3.40.0070.01018.79
8.3.30.0040.01119.17
8.3.20.0040.00420.21
8.3.10.0040.00421.96
8.3.00.0060.00319.50
8.2.180.0110.00717.00
8.2.170.0110.00422.96
8.2.160.0100.00320.39
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0060.01226.16
8.2.120.0000.00722.26
8.2.110.0090.00020.56
8.2.100.0120.00017.84
8.2.90.0040.00419.21
8.2.80.0050.00517.97
8.2.70.0040.00417.75
8.2.60.0060.00318.05
8.2.50.0000.00818.07
8.2.40.0030.00519.95
8.2.30.0040.00418.09
8.2.20.0040.00417.85
8.2.10.0000.00718.27
8.2.00.0000.01117.75
8.1.280.0140.00725.92
8.1.270.0000.00823.85
8.1.260.0100.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00022.14
8.1.230.0080.00417.52
8.1.220.0040.00417.79
8.1.210.0060.00318.77
8.1.200.0030.00617.36
8.1.190.0080.00017.53
8.1.180.0060.00318.10
8.1.170.0030.00518.61
8.1.160.0040.00422.06
8.1.150.0080.00318.72
8.1.140.0030.00517.55
8.1.130.0070.00017.78
8.1.120.0040.00417.53
8.1.110.0000.00817.38
8.1.100.0000.00717.43
8.1.90.0000.00817.39
8.1.80.0000.00717.55
8.1.70.0040.00417.50
8.1.60.0060.00317.63
8.1.50.0060.00317.57
8.1.40.0040.00417.53
8.1.30.0040.00417.70
8.1.20.0000.00817.70
8.1.10.0050.00317.53
8.1.00.0000.00817.44
8.0.300.0000.00718.77
8.0.290.0040.00416.88
8.0.280.0030.00318.48
8.0.270.0030.00317.30
8.0.260.0070.00017.31
8.0.250.0070.00017.07
8.0.240.0030.00517.02
8.0.230.0000.00717.05
8.0.220.0050.00216.96
8.0.210.0040.00417.00
8.0.200.0060.00016.93
8.0.190.0030.00617.07
8.0.180.0040.00416.95
8.0.170.0040.00416.95
8.0.160.0000.00717.03
8.0.150.0070.00017.05
8.0.140.0070.00016.92
8.0.130.0030.00313.41
8.0.120.0070.00016.93
8.0.110.0040.00416.97
8.0.100.0040.00416.98
8.0.90.0030.00316.90
8.0.80.0060.01016.97
8.0.70.0040.00416.80
8.0.60.0030.00517.07
8.0.50.0000.00716.98
8.0.30.0110.00717.20
8.0.20.0090.00917.40
8.0.10.0000.00717.11
8.0.00.0110.00716.82
7.4.330.0060.00015.09
7.4.320.0030.00316.65
7.4.300.0000.00816.55
7.4.290.0070.00016.54
7.4.280.0070.00016.52
7.4.270.0040.00416.66
7.4.260.0040.00416.52
7.4.250.0030.00616.46
7.4.240.0030.00316.60
7.4.230.0030.00316.62
7.4.220.0070.01116.66
7.4.210.0070.00716.60
7.4.200.0030.00516.73
7.4.190.0000.00716.64
7.4.160.0130.00316.69
7.4.150.0130.00617.40
7.4.140.0100.01017.86
7.4.130.0080.01116.66
7.4.120.0070.01316.42
7.4.110.0090.00916.50
7.4.100.0130.01316.63
7.4.90.0130.00516.54
7.4.80.0060.01219.39
7.4.70.0100.00716.70
7.4.60.0060.01916.63
7.4.50.0000.00416.48
7.4.40.0000.01422.77
7.4.30.0070.01016.69
7.4.00.0040.00814.97
7.3.330.0030.00313.34
7.3.320.0060.00013.33
7.3.310.0000.00716.50
7.3.300.0030.00316.48
7.3.290.0150.00416.44
7.3.280.0080.00916.48
7.3.270.0030.01417.40
7.3.260.0190.00316.64
7.3.250.0120.00816.46
7.3.240.0070.01016.61
7.3.230.0100.00616.48
7.3.210.0100.00616.39
7.3.200.0060.01619.39
7.3.190.0080.01516.56
7.3.180.0090.00616.72
7.3.170.0090.00616.39
7.3.160.0100.01016.58
7.3.120.0090.00615.10
7.2.330.0090.00916.59
7.2.320.0070.01316.73
7.2.310.0080.00816.68
7.2.300.0070.01316.88
7.2.290.0160.00016.54
7.1.70.0110.00316.84
7.1.60.0140.01119.46
7.1.50.0030.01016.76
7.1.00.0030.07722.50
7.0.200.0210.00616.76
7.0.140.0030.07321.95
7.0.60.0030.06320.01
7.0.50.0070.08017.90
7.0.40.0130.07320.20
7.0.30.0570.06720.17
7.0.20.0200.03720.21
7.0.10.0200.04320.30
7.0.00.0100.06020.03
5.6.280.0070.07020.88
5.6.210.0100.08320.58
5.6.200.0030.08018.13
5.6.190.0030.06720.57
5.6.180.0230.04020.48
5.6.170.0370.06720.55
5.6.160.0070.07320.54
5.6.150.0070.08018.28
5.6.140.0030.08318.28
5.6.130.0130.03318.14
5.6.120.0200.07321.15
5.6.110.0100.04020.91
5.6.100.0130.08021.14
5.6.90.0030.04021.02
5.6.80.0170.07020.42
5.6.70.3570.04720.39
5.5.350.0270.06020.44
5.5.340.0030.05018.05
5.5.330.0170.07320.46
5.5.320.0330.05020.35
5.5.310.0200.07720.29
5.5.300.0170.06317.95
5.5.290.0100.05717.93
5.5.280.0070.04720.97
5.5.270.0070.04320.78
5.5.260.0130.08320.91
5.5.250.0170.02720.70
5.5.240.0170.05020.37
5.4.450.0570.06019.47
5.4.440.0630.05319.58
5.4.430.0800.04319.44
5.4.420.0230.04319.14
5.4.410.0870.05719.46
5.4.400.0570.05719.14
5.4.390.0600.05319.05
5.4.380.0430.07318.79
5.4.370.0500.04718.57
5.4.360.0330.05318.54
5.4.350.0370.05018.77
5.4.340.0230.05718.60
5.4.320.0080.04512.52
5.4.310.0080.03712.51
5.4.300.0060.03712.52
5.4.290.0070.04112.50
5.4.280.0090.03712.40
5.4.270.0110.03212.39
5.4.260.0090.04112.39
5.4.250.0080.05112.39
5.4.240.0050.04312.40
5.4.230.0040.04012.39
5.4.220.0070.03512.39
5.4.210.0050.03712.39
5.4.200.0060.04212.39
5.4.190.0090.04712.38
5.4.180.0100.05012.39
5.4.170.0060.04112.39
5.4.160.0030.05012.39
5.4.150.0080.04512.39
5.4.140.0090.05112.07
5.4.130.0120.04512.06
5.4.120.0050.05012.01
5.4.110.0080.04412.01
5.4.100.0090.04512.02
5.4.90.0090.05412.02
5.4.80.0130.06012.01
5.4.70.0100.04412.01
5.4.60.0030.04612.01
5.4.50.0070.04312.00
5.4.40.0060.03512.00
5.4.30.0050.04011.99
5.4.20.0070.03511.99
5.4.10.0080.03211.99
5.4.00.0050.03711.48
5.3.290.0070.04012.80
5.3.280.0110.03412.71
5.3.270.0040.04412.73
5.3.260.0050.04312.72
5.3.250.0060.04212.72
5.3.240.0050.04112.71
5.3.230.0060.04012.71
5.3.220.0050.03912.68
5.3.210.0060.04212.68
5.3.200.0050.03812.68
5.3.190.0040.04012.68
5.3.180.0050.03912.67
5.3.170.0060.03812.67
5.3.160.0060.03812.67
5.3.150.0050.03912.67
5.3.140.0080.03912.66
5.3.130.0080.03812.65
5.3.120.0040.04112.65
5.3.110.0040.04012.66
5.3.100.0050.03812.13
5.3.90.0040.03812.12
5.3.80.0030.03912.11
5.3.70.0060.03812.11
5.3.60.0040.03912.09
5.3.50.0110.03212.04
5.3.40.0060.03612.04
5.3.30.0060.03512.00
5.3.20.0070.03811.78
5.3.10.0060.03511.75
5.3.00.0050.04311.74
5.2.170.0050.0319.24
5.2.160.0070.0279.24
5.2.150.0030.0339.24
5.2.140.0050.0319.24
5.2.130.0050.0289.20
5.2.120.0020.0319.20
5.2.110.0040.0309.20
5.2.100.0030.0319.20
5.2.90.0040.0299.19
5.2.80.0040.0329.20
5.2.70.0050.0309.19
5.2.60.0070.0289.15
5.2.50.0030.0319.12
5.2.40.0060.0409.10
5.2.30.0050.0359.07
5.2.20.0030.0309.05
5.2.10.0040.0298.95
5.2.00.0040.0298.83
5.1.60.0040.0248.11
5.1.50.0050.0248.11
5.1.40.0040.0248.09
5.1.30.0030.0278.43
5.1.20.0060.0258.46
5.1.10.0020.0288.18
5.1.00.0070.0238.18
5.0.50.0030.0216.68
5.0.40.0020.0206.53
5.0.30.0040.0306.34
5.0.20.0040.0186.31
5.0.10.0020.0216.29
5.0.00.0020.0326.28
4.4.90.0030.0154.77
4.4.80.0050.0134.75
4.4.70.0010.0184.75
4.4.60.0020.0164.76
4.4.50.0010.0174.77
4.4.40.0030.0254.71
4.4.30.0050.0134.76
4.4.20.0030.0164.85
4.4.10.0030.0154.85
4.4.00.0050.0234.75
4.3.110.0010.0174.67
4.3.100.0030.0144.67
4.3.90.0010.0164.63
4.3.80.0010.0264.58
4.3.70.0050.0124.63
4.3.60.0030.0144.63
4.3.50.0030.0154.63
4.3.40.0020.0244.54
4.3.30.0030.0173.30
4.3.20.0050.0133.28
4.3.10.0040.0143.24
4.3.00.0000.01310.54

preferences:
46.25 ms | 401 KiB | 5 Q