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(){ $func = function(){ $test->secret = "edef blah"; }; return $func->bindTo($test, '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.0070.00716.75
8.3.50.0100.01022.04
8.3.40.0120.00618.86
8.3.30.0150.00019.21
8.3.20.0050.00320.29
8.3.10.0040.00423.66
8.3.00.0060.00319.38
8.2.180.0110.01118.54
8.2.170.0120.00322.96
8.2.160.0030.01020.43
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0110.00726.16
8.2.120.0080.00022.25
8.2.110.0050.00522.26
8.2.100.0000.01218.03
8.2.90.0050.00319.17
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0090.00017.93
8.2.50.0040.00418.07
8.2.40.0060.00320.07
8.2.30.0040.00418.10
8.2.20.0040.00417.80
8.2.10.0070.00018.15
8.2.00.0040.00417.70
8.1.280.0070.00725.92
8.1.270.0080.00023.97
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.91
8.1.230.0060.00618.97
8.1.220.0090.00017.79
8.1.210.0040.00418.77
8.1.200.0040.00417.35
8.1.190.0080.00017.53
8.1.180.0090.00018.10
8.1.170.0030.00718.51
8.1.160.0070.00021.92
8.1.150.0050.00518.61
8.1.140.0070.00017.48
8.1.130.0000.00717.81
8.1.120.0070.00017.40
8.1.110.0040.00417.40
8.1.100.0050.00317.39
8.1.90.0000.00717.49
8.1.80.0000.00717.45
8.1.70.0000.00817.43
8.1.60.0040.00417.59
8.1.50.0050.00317.55
8.1.40.0050.00317.56
8.1.30.0040.00417.57
8.1.20.0000.00717.69
8.1.10.0030.00617.59
8.1.00.0000.00717.59
8.0.300.0000.00720.78
8.0.290.0070.00017.16
8.0.280.0000.00718.50
8.0.270.0040.00417.29
8.0.260.0080.00018.48
8.0.250.0030.00317.12
8.0.240.0040.00416.92
8.0.230.0040.00417.05
8.0.220.0000.00717.02
8.0.210.0000.00716.96
8.0.200.0000.00717.03
8.0.190.0040.00417.09
8.0.180.0040.00416.94
8.0.170.0040.00417.00
8.0.160.0030.00416.86
8.0.150.0000.00716.94
8.0.140.0000.00716.93
8.0.130.0000.00613.48
8.0.120.0030.00516.91
8.0.110.0080.00016.92
8.0.100.0000.00816.98
8.0.90.0040.00416.95
8.0.80.0030.01216.97
8.0.70.0040.00416.94
8.0.60.0000.00717.05
8.0.50.0030.00316.89
8.0.30.0100.01217.16
8.0.20.0120.00717.40
8.0.10.0040.00417.13
8.0.00.0090.00916.95
7.4.330.0000.00515.13
7.4.320.0000.00716.59
7.4.300.0040.00416.43
7.4.290.0070.00016.55
7.4.280.0000.00716.43
7.4.270.0030.00616.63
7.4.260.0040.00416.63
7.4.250.0000.00816.53
7.4.240.0040.00316.63
7.4.230.0030.00316.70
7.4.220.0040.01516.57
7.4.210.0090.00616.55
7.4.200.0040.00416.29
7.4.190.0070.00016.71
7.4.160.0130.00316.36
7.4.150.0120.00617.40
7.4.140.0130.00517.86
7.4.130.0050.01216.55
7.4.120.0100.00816.68
7.4.110.0040.01416.58
7.4.100.0120.01216.57
7.4.90.0040.01716.65
7.4.80.0110.00919.39
7.4.70.0080.00916.59
7.4.60.0060.01216.44
7.4.50.0060.00316.73
7.4.40.0100.00722.77
7.4.30.0100.00716.42
7.4.00.0040.01414.88
7.3.330.0030.00313.46
7.3.320.0050.00013.24
7.3.310.0000.00716.56
7.3.300.0000.00716.45
7.3.290.0070.01316.46
7.3.280.0070.00816.49
7.3.270.0120.00617.40
7.3.260.0160.01716.42
7.3.250.0130.00616.59
7.3.240.0120.00416.64
7.3.230.0060.01016.57
7.3.210.0110.00616.55
7.3.200.0140.00316.54
7.3.190.0140.00316.55
7.3.180.0060.01016.45
7.3.170.0030.01316.46
7.3.160.0040.01416.59
7.3.120.0100.00315.08
7.2.330.0120.00816.77
7.2.320.0100.00716.86
7.2.310.0040.01216.70
7.2.300.0120.00916.50
7.2.290.0000.01716.93
7.2.60.0040.00816.57
7.2.00.0060.00919.53
7.1.200.0000.01415.92
7.1.100.0030.00618.04
7.1.70.0030.00317.25
7.1.60.0080.00419.46
7.1.50.0100.02016.50
7.1.00.0000.07322.31
7.0.200.0070.00316.86
7.0.140.0070.07022.07
7.0.60.0000.08319.99
7.0.50.0100.06317.91
7.0.40.0030.06020.30
7.0.30.0370.05020.07
7.0.20.0200.08720.19
7.0.10.0170.08020.11
7.0.00.0070.04020.24
5.6.280.0070.07020.93
5.6.210.0070.03720.73
5.6.200.0030.08718.14
5.6.190.0070.05020.52
5.6.180.0230.07720.77
5.6.170.0170.07020.55
5.6.160.0030.05320.46
5.6.150.0130.07718.17
5.6.140.0170.07018.18
5.6.130.0030.08718.24
5.6.120.0030.04020.99
5.6.110.0070.08321.11
5.6.100.0000.06321.02
5.6.90.0130.04021.03
5.6.80.0000.04320.40
5.6.70.4130.03320.38
5.5.350.0400.06720.39
5.5.340.0030.03717.97
5.5.330.0000.05020.31
5.5.320.0370.07020.32
5.5.310.0170.04020.34
5.5.300.0030.04018.00
5.5.290.0170.07718.07
5.5.280.0100.07020.82
5.5.270.0100.07020.77
5.5.260.0030.04020.75
5.5.250.0170.03320.59
5.5.240.3500.03020.21
5.4.450.0670.04719.38
5.4.440.0630.08319.69
5.4.430.0230.05019.57
5.4.420.0670.04719.36
5.4.410.0130.05019.53
5.4.400.0300.07319.13
5.4.390.0730.04319.22
5.4.380.0430.05018.77
5.4.370.0430.07018.77
5.4.360.0330.04718.64
5.4.350.0400.04718.74
5.4.340.0270.06318.71
5.4.320.0060.03812.52
5.4.310.0100.03812.52
5.4.300.0090.03712.52
5.4.290.0070.03912.50
5.4.280.0080.03812.40
5.4.270.0080.03712.40
5.4.260.0060.03912.40
5.4.250.0070.03912.40
5.4.240.0060.03712.40
5.4.230.0060.03712.39
5.4.220.0040.04412.39
5.4.210.0090.04412.39
5.4.200.0060.03812.39
5.4.190.0060.03812.39
5.4.180.0040.04012.39
5.4.170.0060.04212.39
5.4.160.0060.03812.39
5.4.150.0060.03612.39
5.4.140.0060.03712.07
5.4.130.0060.03512.06
5.4.120.0060.03512.02
5.4.110.0040.03712.02
5.4.100.0030.03712.02
5.4.90.0120.04712.01
5.4.80.0040.03812.01
5.4.70.0070.05012.01
5.4.60.0110.04612.01
5.4.50.0090.05312.01
5.4.40.0100.05012.00
5.4.30.0080.04911.99
5.4.20.0100.05012.00
5.4.10.0070.05312.00
5.4.00.0100.04911.48
5.3.290.0090.03612.80
5.3.280.0050.05612.71
5.3.270.0090.05812.72
5.3.260.0090.05612.72
5.3.250.0100.05312.72
5.3.240.0090.05312.72
5.3.230.0110.04812.71
5.3.220.0090.03712.68
5.3.210.0160.04812.68
5.3.200.0050.05512.68
5.3.190.0100.05012.68
5.3.180.0130.04812.68
5.3.170.0090.05312.67
5.3.160.0060.05412.67
5.3.150.0090.05312.67
5.3.140.0080.05312.66
5.3.130.0070.05612.66
5.3.120.0090.05412.66
5.3.110.0060.05612.66
5.3.100.0100.04812.14
5.3.90.0090.05112.12
5.3.80.0070.05012.11
5.3.70.0120.04612.12
5.3.60.0080.04912.09
5.3.50.0070.05012.04
5.3.40.0120.04512.05
5.3.30.0070.05012.01
5.3.20.0060.05011.79
5.3.10.0030.05411.75
5.3.00.0070.05111.74
5.2.170.0060.0439.24
5.2.160.0080.0419.25
5.2.150.0050.0439.24
5.2.140.0050.0429.24
5.2.130.0050.0439.20
5.2.120.0090.0379.20
5.2.110.0080.0369.20
5.2.100.0040.0389.20
5.2.90.0050.0419.20
5.2.80.0030.0449.19
5.2.70.0080.0409.19
5.2.60.0080.0399.15
5.2.50.0110.0359.12
5.2.40.0050.0389.10
5.2.30.0100.0369.07
5.2.20.0060.0389.06
5.2.10.0080.0348.95
5.2.00.0090.0368.83
5.1.60.0110.0288.11
5.1.50.0080.0298.10
5.1.40.0040.0348.09
5.1.30.0070.0248.43
5.1.20.0070.0298.46
5.1.10.0040.0268.19
5.1.00.0100.0278.18
5.0.50.0040.0256.68
5.0.40.0070.0246.53
5.0.30.0050.0336.35
5.0.20.0030.0226.31
5.0.10.0060.0246.29
5.0.00.0020.0406.28
4.4.90.0090.0154.78
4.4.80.0050.0214.76
4.4.70.0080.0184.75
4.4.60.0090.0184.75
4.4.50.0040.0224.77
4.4.40.0060.0284.70
4.4.30.0030.0214.76
4.4.20.0060.0174.84
4.4.10.0040.0184.85
4.4.00.0030.0364.76
4.3.110.0030.0234.67
4.3.100.0050.0174.67
4.3.90.0020.0204.63
4.3.80.0020.0294.58
4.3.70.0040.0174.63
4.3.60.0040.0204.63
4.3.50.0020.0194.63
4.3.40.0040.0274.54
4.3.30.0020.0193.30
4.3.20.0030.0183.28
4.3.10.0040.0173.24
4.3.00.0130.01310.54

preferences:
47.85 ms | 401 KiB | 5 Q