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'); } $test->__set('secret' , closey($test) ); // 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.0140.00016.75
8.3.50.0120.00621.99
8.3.40.0140.00418.94
8.3.30.0110.00319.09
8.3.20.0000.00720.51
8.3.10.0030.00623.65
8.3.00.0060.00319.40
8.2.180.0090.00918.66
8.2.170.0060.01222.96
8.2.160.0070.00720.28
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0070.01126.16
8.2.120.0040.00422.27
8.2.110.0100.00019.33
8.2.100.0060.00617.82
8.2.90.0050.00519.15
8.2.80.0000.00917.97
8.2.70.0030.00617.75
8.2.60.0060.00318.03
8.2.50.0060.00318.07
8.2.40.0040.00419.88
8.2.30.0030.00518.07
8.2.20.0000.00817.95
8.2.10.0020.00518.21
8.2.00.0070.00417.93
8.1.280.0070.00725.92
8.1.270.0080.00023.88
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0060.00322.06
8.1.230.0040.01118.86
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0100.00017.25
8.1.190.0060.00317.36
8.1.180.0000.00718.10
8.1.170.0000.01018.43
8.1.160.0050.00222.09
8.1.150.0050.00518.58
8.1.140.0070.00317.56
8.1.130.0040.00417.93
8.1.120.0000.00717.49
8.1.110.0000.00717.51
8.1.100.0030.00317.50
8.1.90.0000.00817.50
8.1.80.0030.00317.50
8.1.70.0070.00017.46
8.1.60.0030.00617.46
8.1.50.0000.00817.45
8.1.40.0000.00817.46
8.1.30.0000.00817.49
8.1.20.0040.00417.66
8.1.10.0040.00417.61
8.1.00.0000.00717.52
8.0.300.0050.00318.77
8.0.290.0040.00416.75
8.0.280.0040.00418.48
8.0.270.0000.00717.29
8.0.260.0060.00017.29
8.0.250.0070.00017.05
8.0.240.0000.00717.12
8.0.230.0040.00417.08
8.0.220.0030.00316.90
8.0.210.0070.00017.02
8.0.200.0070.00017.03
8.0.190.0060.00316.98
8.0.180.0030.00517.00
8.0.170.0030.00517.00
8.0.160.0000.00717.06
8.0.150.0030.00516.98
8.0.140.0000.00716.96
8.0.130.0000.00613.48
8.0.120.0040.00416.81
8.0.110.0040.00416.88
8.0.100.0050.00216.99
8.0.90.0040.00417.04
8.0.80.0090.00616.92
8.0.70.0040.00417.04
8.0.60.0050.00316.81
8.0.50.0040.00416.87
8.0.30.0100.00917.28
8.0.20.0140.01117.43
8.0.10.0040.00417.07
8.0.00.0080.01016.84
7.4.330.0000.00515.00
7.4.320.0000.00616.56
7.4.300.0000.00616.53
7.4.290.0030.00316.64
7.4.280.0000.00716.64
7.4.270.0000.00716.66
7.4.260.0030.00316.48
7.4.250.0040.00416.43
7.4.240.0030.00316.57
7.4.230.0030.00316.75
7.4.220.0110.00616.68
7.4.210.0080.00716.71
7.4.200.0040.00416.35
7.4.190.0000.00716.59
7.4.160.0120.00416.54
7.4.150.0000.01717.40
7.4.140.0090.01117.86
7.4.130.0100.00916.69
7.4.120.0100.01016.65
7.4.110.0150.00316.67
7.4.100.0070.01116.71
7.4.90.0160.00616.62
7.4.80.0070.01319.39
7.4.70.0070.01016.65
7.4.60.0030.01416.49
7.4.50.0050.00316.46
7.4.40.0110.00422.77
7.4.30.0080.00816.48
7.4.10.0120.00614.94
7.4.00.0090.00515.01
7.3.330.0030.00313.48
7.3.320.0030.00313.44
7.3.310.0070.00016.28
7.3.300.0060.00316.43
7.3.290.0090.00716.47
7.3.280.0080.00816.46
7.3.270.0100.00717.40
7.3.260.0000.01816.46
7.3.250.0070.01216.71
7.3.240.0100.00616.74
7.3.230.0140.00716.67
7.3.210.0070.01116.45
7.3.200.0100.01319.39
7.3.190.0090.01216.51
7.3.180.0130.00316.41
7.3.170.0060.01016.56
7.3.160.0140.00716.82
7.3.130.0100.00714.66
7.3.120.0040.01314.80
7.3.110.0070.01115.05
7.3.100.0070.00714.91
7.3.90.0100.00614.93
7.3.80.0060.00914.86
7.3.70.0120.00314.63
7.3.60.0090.00614.99
7.3.50.0030.00715.02
7.3.40.0030.00914.90
7.3.30.0030.00614.95
7.3.20.0000.00916.61
7.3.10.0030.01316.41
7.3.00.0110.00016.46
7.2.330.0090.00916.76
7.2.320.0060.01016.80
7.2.310.0030.01316.50
7.2.300.0060.01016.88
7.2.290.0040.01216.40
7.2.260.0040.01215.09
7.2.250.0060.01015.38
7.2.240.0070.01014.99
7.2.230.0030.01414.99
7.2.220.0070.00715.05
7.2.210.0030.01215.02
7.2.200.0090.00615.19
7.2.190.0030.01315.24
7.2.180.0120.00015.18
7.2.170.0060.00315.21
7.2.160.0030.00915.25
7.2.150.0030.01316.98
7.2.140.0110.00417.19
7.2.130.0070.00716.91
7.2.120.0040.01517.11
7.2.110.0070.00716.87
7.2.100.0070.00717.07
7.2.90.0000.01417.20
7.2.80.0140.00316.98
7.2.70.0070.00717.03
7.2.60.0100.00716.69
7.2.50.0100.00717.10
7.2.40.0100.00317.08
7.2.30.0100.00317.14
7.2.20.0090.00616.76
7.2.10.0090.00616.66
7.2.00.0170.00918.21
7.1.330.0060.00816.10
7.1.320.0070.01116.04
7.1.310.0090.00615.62
7.1.300.0100.00015.63
7.1.290.0030.00915.94
7.1.280.0070.00715.74
7.1.270.0090.00615.65
7.1.260.0120.00415.62
7.1.250.0090.00615.78
7.1.240.0090.00015.86
7.1.230.0030.00615.55
7.1.220.0090.00615.76
7.1.210.0070.00715.71
7.1.200.0070.00715.85
7.1.190.0070.01015.83
7.1.180.0000.01115.98
7.1.170.0070.00715.89
7.1.160.0100.00315.75
7.1.150.0070.00315.90
7.1.140.0090.00615.69
7.1.130.0030.01015.71
7.1.120.0090.00415.88
7.1.110.0000.00815.50
7.1.100.0070.00517.12
7.1.90.0040.01116.03
7.1.80.0070.01015.91
7.1.70.0040.00416.61
7.1.60.0090.00917.71
7.1.50.0080.01016.52
7.1.40.0030.00915.63
7.1.30.0110.00315.86
7.1.20.0100.00615.60
7.1.10.0090.00315.68
7.1.00.0060.04119.08
7.0.330.0100.00715.20
7.0.320.0040.00815.35
7.0.310.0030.00615.45
7.0.300.0030.01315.27
7.0.290.0060.00815.23
7.0.280.0070.00315.67
7.0.270.0070.00715.62
7.0.260.0040.00415.36
7.0.250.0080.00315.30
7.0.240.0070.00715.38
7.0.230.0000.01415.47
7.0.220.0040.01115.40
7.0.210.0030.00915.32
7.0.200.0030.00716.10
7.0.190.0040.01115.20
7.0.180.0090.00015.41
7.0.170.0090.00315.50
7.0.160.0100.00315.32
7.0.150.0100.00015.50
7.0.140.0050.03818.66
7.0.130.0070.00715.21
7.0.120.0050.00515.27
7.0.110.0040.00415.37
7.0.100.0030.00715.45
7.0.90.0000.01415.47
7.0.80.0070.00415.59
7.0.70.0040.01115.65
7.0.60.0050.02317.76
7.0.50.0070.03716.65
7.0.40.0090.03016.89
7.0.30.0320.02916.91
7.0.20.0130.02416.78
7.0.10.0060.04516.84
7.0.00.0080.04616.90
5.6.400.0030.00714.36
5.6.390.0100.00713.93
5.6.380.0080.00814.54
5.6.370.0030.00914.09
5.6.360.0070.00714.22
5.6.350.0000.01414.56
5.6.340.0030.00914.31
5.6.330.0040.01114.46
5.6.320.0120.00014.06
5.6.310.0120.00314.43
5.6.300.0080.00414.46
5.6.290.0060.00614.59
5.6.280.0110.03017.75
5.6.270.0070.00314.32
5.6.260.0040.00714.56
5.6.250.0040.01114.57
5.6.240.0000.01214.41
5.6.230.0060.00614.34
5.6.220.0030.01014.34
5.6.210.0060.04617.61
5.6.200.0020.04316.35
5.6.190.0050.05217.54
5.6.180.0110.02617.41
5.6.170.0210.02917.51
5.6.160.0070.04517.55
5.6.150.0030.03316.22
5.6.140.0050.02616.15
5.6.130.0060.04516.30
5.6.120.0070.04517.69
5.6.110.0130.04317.58
5.6.100.0050.02417.76
5.6.90.0030.02517.77
5.6.80.0040.04517.47
5.6.70.2270.02017.45
5.6.60.0030.00614.20
5.6.50.0070.00714.14
5.6.40.0060.01214.24
5.6.30.0070.00714.24
5.6.20.0060.00814.37
5.6.10.0000.01314.09
5.6.00.0070.00714.04
5.5.380.0030.00814.54
5.5.370.0130.00014.27
5.5.360.0040.00714.57
5.5.350.0000.04817.37
5.5.340.0090.04016.22
5.5.330.0080.04317.60
5.5.320.0070.04517.35
5.5.310.0200.03317.31
5.5.300.0080.04316.31
5.5.290.0030.02616.17
5.5.280.0060.04117.45
5.5.270.0080.02717.59
5.5.260.0090.04217.70
5.5.250.0130.03417.54
5.5.240.0100.04017.30
5.5.230.0000.01214.13
5.5.220.0060.00914.24
5.5.210.0030.00914.47
5.5.200.0060.01014.40
5.5.190.0070.00714.18
5.5.180.0030.01414.33
5.5.170.0000.01214.43
5.5.160.0070.00714.44
5.5.150.0060.00614.03
5.5.140.0070.00714.09
5.5.130.0090.00614.46
5.5.120.0030.01013.98
5.5.110.0030.01114.38
5.5.100.0030.01014.39
5.5.90.0070.00714.55
5.5.80.0030.01114.12
5.5.70.0000.01414.37
5.5.60.0100.00314.12
5.5.50.0030.01014.43
5.5.40.0070.01014.22
5.5.30.0090.00614.41
5.5.20.0060.01014.36
5.5.10.0000.00913.78
5.5.00.0070.00714.23
5.4.450.0240.01815.94
5.4.440.0020.02315.78
5.4.430.0200.02415.88
5.4.420.0280.02715.76
5.4.410.0480.02815.81
5.4.400.0100.02015.61
5.4.390.0270.02415.72
5.4.380.0150.04015.55
5.4.370.0200.03315.49
5.4.360.0180.03915.48
5.4.350.0190.02915.43
5.4.340.0130.03415.57
5.4.330.0000.01212.35
5.4.320.0050.02012.44
5.4.310.0040.02612.43
5.4.300.0080.02312.44
5.4.290.0070.03812.43
5.4.280.0050.03412.37
5.4.270.0060.04312.38
5.4.260.0090.06012.38
5.4.250.0070.03912.38
5.4.240.0110.03212.38
5.4.230.0060.03112.37
5.4.220.0040.03212.37
5.4.210.0050.03112.37
5.4.200.0060.02412.37
5.4.190.0070.02112.37
5.4.180.0050.02412.37
5.4.170.0070.02212.38
5.4.160.0050.02212.37
5.4.150.0060.02112.37
5.4.140.0050.02312.21
5.4.130.0040.02312.21
5.4.120.0020.02412.19
5.4.110.0070.01912.18
5.4.100.0050.02312.18
5.4.90.0060.02112.18
5.4.80.0050.02312.18
5.4.70.0090.01712.18
5.4.60.0050.02412.18
5.4.50.0020.02412.18
5.4.40.0030.02212.17
5.4.30.0040.02312.17
5.4.20.0070.01812.17
5.4.10.0020.02412.17
5.4.00.0020.02511.92
5.3.290.0090.01812.57
5.3.280.0040.02412.53
5.3.270.0030.02412.54
5.3.260.0050.02212.54
5.3.250.0040.02312.53
5.3.240.0040.02412.54
5.3.230.0090.01912.53
5.3.220.0060.01912.52
5.3.210.0070.02312.52
5.3.200.0070.02112.52
5.3.190.0070.02012.51
5.3.180.0060.02012.51
5.3.170.0050.02312.51
5.3.160.0040.02312.51
5.3.150.0060.01912.51
5.3.140.0080.02712.51
5.3.130.0080.02612.51
5.3.120.0030.02712.50
5.3.110.0060.02112.50
5.3.100.0040.02212.24
5.3.90.0090.01812.23
5.3.80.0100.02312.23
5.3.70.0080.02712.23
5.3.60.0050.02512.22
5.3.50.0090.03112.20
5.3.40.0040.04212.20
5.3.30.0050.02812.19
5.3.20.0020.02512.07
5.3.10.0090.01812.05
5.3.00.0020.02412.05
5.2.170.0060.0389.24
5.2.160.0060.0289.25
5.2.150.0050.0309.25
5.2.140.0040.0329.24
5.2.130.0030.0319.20
5.2.120.0050.0309.20
5.2.110.0060.0309.20
5.2.100.0040.0319.20
5.2.90.0070.0359.20
5.2.80.0050.0319.19
5.2.70.0080.0329.19
5.2.60.0040.0319.15
5.2.50.0070.0309.12
5.2.40.0050.0299.10
5.2.30.0030.0319.07
5.2.20.0070.0369.05
5.2.10.0100.0768.95
5.2.00.0090.0548.83
5.1.60.0070.0528.11
5.1.50.0060.0318.11
5.1.40.0040.0358.09
5.1.30.0040.0378.44
5.1.20.0150.0698.46
5.1.10.0100.0398.18
5.1.00.0080.0388.19
5.0.50.0050.0306.67
5.0.40.0040.0266.53
5.0.30.0050.0446.34
5.0.20.0040.0246.31
5.0.10.0020.0236.29
5.0.00.0070.0306.28
4.4.90.0050.0174.78
4.4.80.0040.0174.75
4.4.70.0050.0164.75
4.4.60.0040.0214.76
4.4.50.0030.0184.77
4.4.40.0110.0664.71
4.4.30.0050.0324.76
4.4.20.0040.0304.84
4.4.10.0050.0264.85
4.4.00.0050.0434.76
4.3.110.0140.0374.67
4.3.100.0070.0504.67
4.3.90.0050.0204.63
4.3.80.0020.0404.58
4.3.70.0040.0244.63
4.3.60.0030.0274.63
4.3.50.0030.0284.63
4.3.40.0050.0404.54
4.3.30.0030.0243.30
4.3.20.0020.0243.28
4.3.10.0040.0253.23
4.3.00.0170.01013.17

preferences:
45.47 ms | 401 KiB | 5 Q