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' , 'closey' ); // 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.0120.00316.63
8.3.50.0090.01122.12
8.3.40.0150.00319.06
8.3.30.0140.00419.10
8.3.20.0030.00520.21
8.3.10.0040.00423.71
8.3.00.0050.00319.25
8.2.180.0110.01118.42
8.2.170.0070.00722.96
8.2.160.0070.00720.29
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0100.00726.16
8.2.120.0040.00422.21
8.2.110.0060.00320.81
8.2.100.0090.00317.97
8.2.90.0050.00318.16
8.2.80.0000.00818.09
8.2.70.0060.00317.75
8.2.60.0040.00417.75
8.2.50.0040.00417.63
8.2.40.0040.00419.30
8.2.30.0040.00417.89
8.2.20.0000.00717.77
8.2.10.0040.00418.15
8.2.00.0080.00317.84
8.1.280.0100.00725.92
8.1.270.0090.00024.02
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0030.00622.59
8.1.230.0090.00320.86
8.1.220.0060.00317.74
8.1.210.0100.00018.77
8.1.200.0030.00517.47
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0030.00619.03
8.1.160.0040.00418.91
8.1.150.0000.01018.72
8.1.140.0080.00017.49
8.1.130.0000.00817.88
8.1.120.0040.00417.52
8.1.110.0000.00717.51
8.1.100.0040.00317.50
8.1.90.0040.00417.52
8.1.80.0020.00517.52
8.1.70.0070.00017.36
8.1.60.0050.00517.51
8.1.50.0040.00417.61
8.1.40.0030.00617.45
8.1.30.0000.00817.68
8.1.20.0040.00417.64
8.1.10.0060.00317.60
8.1.00.0040.00417.40
8.0.300.0050.00519.80
8.0.290.0040.00416.63
8.0.280.0000.00718.09
8.0.270.0050.00218.12
8.0.260.0040.00417.40
8.0.250.0030.00317.07
8.0.240.0040.00416.93
8.0.230.0050.00217.10
8.0.220.0030.00316.87
8.0.210.0030.00316.90
8.0.200.0030.00316.94
8.0.190.0050.00317.02
8.0.180.0070.00016.91
8.0.170.0030.00516.95
8.0.160.0040.00416.89
8.0.150.0040.00416.91
8.0.140.0040.00416.85
8.0.130.0000.00613.46
8.0.120.0050.00316.89
8.0.110.0060.00316.99
8.0.100.0020.00516.95
8.0.90.0000.00716.94
8.0.80.0080.00816.97
8.0.70.0040.00416.95
8.0.60.0040.00416.94
8.0.50.0000.00716.89
8.0.30.0100.01117.22
8.0.20.0090.00917.40
8.0.10.0000.00717.07
8.0.00.0110.00716.79
7.4.330.0000.00515.02
7.4.320.0060.00016.66
7.4.300.0070.00016.70
7.4.290.0030.00316.57
7.4.280.0040.00416.64
7.4.270.0000.00716.54
7.4.260.0040.00416.58
7.4.250.0000.00816.45
7.4.240.0040.00316.58
7.4.230.0030.00316.63
7.4.220.0110.00616.73
7.4.210.0080.00916.57
7.4.200.0000.00816.41
7.4.190.0000.00716.68
7.4.160.0060.00916.73
7.4.150.0100.00717.40
7.4.140.0060.01317.86
7.4.130.0060.01316.56
7.4.120.0080.01016.59
7.4.110.0140.00316.47
7.4.100.0180.00416.59
7.4.90.0100.00716.55
7.4.80.0140.01119.39
7.4.70.0070.01116.66
7.4.60.0140.01116.45
7.4.50.0000.00516.34
7.4.40.0070.01122.77
7.4.30.0100.01316.58
7.4.00.0090.00615.09
7.3.330.0000.00513.43
7.3.320.0000.00613.33
7.3.310.0000.00716.38
7.3.300.0080.00016.51
7.3.290.0140.00016.40
7.3.280.0060.01016.48
7.3.270.0100.00717.40
7.3.260.0070.01016.51
7.3.250.0180.00416.70
7.3.240.0160.00416.48
7.3.230.0130.00716.39
7.3.210.0070.01316.68
7.3.200.0060.01719.39
7.3.190.0100.00716.34
7.3.180.0050.01016.47
7.3.170.0130.01016.68
7.3.160.0070.01016.53
7.3.120.0100.00714.94
7.3.10.0110.00316.56
7.3.00.0030.00716.39
7.2.330.0140.00416.81
7.2.320.0090.01316.43
7.2.310.0140.00416.67
7.2.300.0100.00716.82
7.2.290.0130.01016.79
7.2.130.0030.00917.01
7.2.120.0070.00716.92
7.2.110.0070.00716.89
7.2.100.0080.00316.68
7.2.90.0070.00716.86
7.2.80.0030.00716.64
7.2.70.0030.00616.88
7.2.60.0050.00916.86
7.2.50.0100.00317.03
7.2.40.0060.00616.96
7.2.30.0100.00616.80
7.2.20.0080.00817.08
7.2.10.0040.01116.72
7.2.00.0080.00818.05
7.1.250.0030.01015.79
7.1.200.0000.01115.97
7.1.100.0000.01218.27
7.1.70.0030.00616.92
7.1.60.0140.01119.46
7.1.50.0090.00617.01
7.1.00.0030.07722.46
7.0.200.0030.00516.81
7.0.140.0070.07021.92
7.0.60.0100.06719.89
7.0.50.0030.06717.93
7.0.40.0130.08020.23
7.0.30.0230.05020.08
7.0.20.0130.04320.23
7.0.10.0030.05020.25
7.0.00.0070.07720.05
5.6.280.0070.07021.01
5.6.210.0030.04020.68
5.6.200.0030.04318.16
5.6.190.0030.05020.63
5.6.180.0300.07720.53
5.6.170.0270.09020.57
5.6.160.0030.04020.55
5.6.150.0070.06318.28
5.6.140.0170.07318.13
5.6.130.0030.05318.27
5.6.120.0170.04020.96
5.6.110.0070.05321.00
5.6.100.0230.07320.99
5.6.90.0030.08721.02
5.6.80.0200.06320.38
5.6.70.3270.03020.38
5.5.350.0270.06720.37
5.5.340.0030.03718.07
5.5.330.0100.08020.38
5.5.320.0230.04320.25
5.5.310.0430.07320.30
5.5.300.0100.08017.94
5.5.290.0000.04717.96
5.5.280.0070.08320.92
5.5.270.0070.08320.77
5.5.260.0000.04320.74
5.5.250.0130.03020.79
5.5.240.3330.03720.30
5.4.450.0570.06019.19
5.4.440.0670.06319.19
5.4.430.0730.05719.38
5.4.420.0700.05719.18
5.4.410.0770.04719.47
5.4.400.0530.05718.88
5.4.390.0130.05319.05
5.4.380.0330.05318.51
5.4.370.0270.06718.74
5.4.360.0400.07318.82
5.4.350.0300.06318.63
5.4.340.0270.05718.54
5.4.320.0090.03412.52
5.4.310.0080.03712.52
5.4.300.0020.04112.52
5.4.290.0070.05512.50
5.4.280.0060.04712.40
5.4.270.0090.03612.40
5.4.260.0100.05512.40
5.4.250.0060.03712.40
5.4.240.0060.03712.40
5.4.230.0100.04112.39
5.4.220.0080.04612.39
5.4.210.0070.04212.39
5.4.200.0070.04212.39
5.4.190.0090.03712.39
5.4.180.0060.05812.39
5.4.170.0070.05512.39
5.4.160.0070.05312.39
5.4.150.0110.04912.39
5.4.140.0060.05912.07
5.4.130.0070.04112.06
5.4.120.0040.04212.02
5.4.110.0070.05512.02
5.4.100.0150.04612.02
5.4.90.0100.04412.01
5.4.80.0130.05812.02
5.4.70.0060.04512.01
5.4.60.0060.04512.01
5.4.50.0120.04412.01
5.4.40.0110.03412.00
5.4.30.0040.04311.99
5.4.20.0090.04412.00
5.4.10.0080.03911.99
5.4.00.0030.04511.48
5.3.290.0080.04112.80
5.3.280.0100.05112.71
5.3.270.0050.04212.73
5.3.260.0030.04312.71
5.3.250.0060.03912.72
5.3.240.0050.03912.72
5.3.230.0040.04012.71
5.3.220.0110.03512.68
5.3.210.0070.06412.68
5.3.200.0090.06612.68
5.3.190.0100.05912.68
5.3.180.0090.07012.67
5.3.170.0090.08112.67
5.3.160.0120.09212.67
5.3.150.0130.07312.67
5.3.140.0080.06212.66
5.3.130.0060.06612.66
5.3.120.0100.06112.65
5.3.110.0090.05312.66
5.3.100.0040.05112.14
5.3.90.0060.04012.12
5.3.80.0070.03912.11
5.3.70.0080.05812.12
5.3.60.0100.04612.09
5.3.50.0090.04912.04
5.3.40.0060.05412.05
5.3.30.0200.04812.01
5.3.20.0070.06311.79
5.3.10.0100.04911.75
5.3.00.0160.06911.74
5.2.170.0080.0689.25
5.2.160.0080.0449.25
5.2.150.0040.0509.25
5.2.140.0040.0529.24
5.2.130.0060.0469.20
5.2.120.0090.0429.20
5.2.110.0120.0439.20
5.2.100.0080.0529.20
5.2.90.0080.0479.20
5.2.80.0090.0459.19
5.2.70.0110.0469.20
5.2.60.0100.0469.15
5.2.50.0080.0539.12
5.2.40.0080.0389.10
5.2.30.0060.0349.07
5.2.20.0050.0379.05
5.2.10.0150.0578.95
5.2.00.0060.0408.82
5.1.60.0070.0298.11
5.1.50.0200.0818.10
5.1.40.0050.0618.09
5.1.30.0110.0418.44
5.1.20.0050.0298.46
5.1.10.0060.0288.18
5.1.00.0030.0408.19
5.0.50.0070.0256.67
5.0.40.0090.0286.53
5.0.30.0070.0426.34
5.0.20.0080.0236.30
5.0.10.0040.0316.29
5.0.00.0070.0406.28
4.4.90.0030.0234.78
4.4.80.0040.0224.76
4.4.70.0050.0324.75
4.4.60.0050.0204.76
4.4.50.0010.0254.77
4.4.40.0030.0434.71
4.4.30.0050.0244.76
4.4.20.0040.0264.84
4.4.10.0050.0234.85
4.4.00.0060.0404.76
4.3.110.0060.0234.67
4.3.100.0050.0224.66
4.3.90.0050.0214.64
4.3.80.0040.0294.59
4.3.70.0030.0144.63
4.3.60.0010.0174.62
4.3.50.0020.0164.62
4.3.40.0030.0254.54
4.3.30.0020.0163.30
4.3.20.0020.0193.28
4.3.10.0000.0183.23
4.3.00.0200.01310.54

preferences:
44.54 ms | 401 KiB | 5 Q