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); function a() { return true; } $array = array(); //$test->__set($secret , $secret[$secret]['yum']); $test->__set('secret' , $secret[$secret[$secret]]); //$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.40.0150.00418.93
8.3.30.0090.00619.30
8.3.20.0040.00420.39
8.3.10.0040.00421.69
8.3.00.0080.00019.38
8.2.170.0040.01122.96
8.2.160.0140.00020.48
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00626.16
8.2.120.0080.00022.13
8.2.110.0040.00422.25
8.2.100.0060.00617.91
8.2.90.0050.00319.25
8.2.80.0000.00917.97
8.2.70.0040.00417.75
8.2.60.0000.00917.74
8.2.50.0040.00418.07
8.2.40.0040.00420.07
8.2.30.0040.00418.08
8.2.20.0080.00017.82
8.2.10.0000.00818.06
8.2.00.0090.00017.79
8.1.270.0040.00423.68
8.1.260.0080.00026.35
8.1.250.0050.00228.09
8.1.240.0030.00623.96
8.1.230.0040.00819.13
8.1.220.0000.00917.76
8.1.210.0000.00818.77
8.1.200.0030.00617.25
8.1.190.0060.00317.39
8.1.180.0060.00319.14
8.1.170.0000.00818.59
8.1.160.0040.00422.11
8.1.150.0030.00618.68
8.1.140.0050.00217.53
8.1.130.0050.00217.89
8.1.120.0050.00217.47
8.1.110.0000.00717.50
8.1.100.0030.00417.51
8.1.90.0040.00417.43
8.1.80.0000.00717.50
8.1.70.0000.00717.43
8.1.60.0040.00417.68
8.1.50.0040.00417.42
8.1.40.0040.00417.45
8.1.30.0040.00417.63
8.1.20.0000.00817.68
8.1.10.0040.00417.52
8.1.00.0040.00417.55
8.0.300.0070.00020.61
8.0.290.0040.00417.18
8.0.280.0000.00718.50
8.0.270.0000.00717.17
8.0.260.0030.00317.23
8.0.250.0000.00716.95
8.0.240.0000.00717.07
8.0.230.0040.00417.09
8.0.220.0070.00016.95
8.0.210.0030.00316.98
8.0.200.0060.00017.07
8.0.190.0040.00417.03
8.0.180.0040.00416.95
8.0.170.0040.00416.92
8.0.160.0040.00416.94
8.0.150.0050.00216.96
8.0.140.0030.00316.84
8.0.130.0000.00613.39
8.0.120.0080.00016.95
8.0.110.0040.00416.95
8.0.100.0000.00717.05
8.0.90.0070.00016.94
8.0.80.0080.00817.00
8.0.70.0040.00416.86
8.0.60.0050.00216.95
8.0.50.0040.00416.81
8.0.30.0050.01417.26
8.0.20.0100.01017.42
8.0.10.0060.00317.18
8.0.00.0060.01216.91
7.4.330.0050.00015.00
7.4.320.0000.00816.46
7.4.300.0070.00016.55
7.4.290.0000.00716.51
7.4.280.0030.00316.54
7.4.270.0000.00816.56
7.4.260.0000.00816.63
7.4.250.0000.00716.64
7.4.240.0030.00316.58
7.4.230.0030.00316.64
7.4.220.0160.00316.41
7.4.210.0080.00616.65
7.4.200.0020.00516.71
7.4.190.0080.00016.35
7.4.160.0070.00716.63
7.4.150.0110.00717.40
7.4.140.0060.01217.86
7.4.130.0060.01116.65
7.4.120.0100.00716.56
7.4.110.0120.00616.52
7.4.100.0180.00616.52
7.4.90.0110.00516.59
7.4.80.0070.01019.39
7.4.70.0030.01416.53
7.4.60.0120.01216.61
7.4.50.0080.00016.82
7.4.40.0090.00622.77
7.4.30.0080.00816.50
7.4.10.0070.01314.80
7.4.00.0070.00915.01
7.3.330.0000.00613.46
7.3.320.0070.00013.47
7.3.310.0030.00416.33
7.3.300.0040.00416.48
7.3.290.0040.00416.43
7.3.280.0110.00616.43
7.3.270.0110.00617.40
7.3.260.0140.01016.51
7.3.250.0150.00916.59
7.3.240.0090.00916.45
7.3.230.0080.00816.63
7.3.210.0150.00316.42
7.3.200.0100.00616.54
7.3.190.0060.01716.54
7.3.180.0160.00016.46
7.3.170.0000.01616.57
7.3.160.0120.00616.48
7.3.130.0070.01115.14
7.3.120.0100.00714.90
7.3.110.0060.01314.92
7.3.100.0030.01014.73
7.3.90.0100.00314.47
7.3.80.0070.00714.81
7.3.70.0100.00714.60
7.3.60.0000.01315.03
7.3.50.0030.00714.90
7.3.40.0040.01115.06
7.3.30.0070.00414.85
7.3.20.0080.00416.60
7.3.10.0090.00516.51
7.3.00.0110.00616.46
7.2.330.0070.01016.66
7.2.320.0100.01316.61
7.2.310.0060.01216.49
7.2.300.0160.00616.81
7.2.290.0120.00416.95
7.2.260.0120.00314.95
7.2.250.0060.01214.74
7.2.240.0030.01215.34
7.2.230.0000.01015.19
7.2.220.0040.01115.16
7.2.210.0070.01015.15
7.2.200.0070.00715.25
7.2.190.0000.01314.83
7.2.180.0120.00014.86
7.2.170.0040.01015.16
7.2.160.0060.00815.02
7.2.150.0150.00017.09
7.2.140.0030.00916.90
7.2.130.0140.00916.71
7.2.120.0110.00816.64
7.2.110.0090.00716.78
7.2.100.0070.00816.82
7.2.90.0020.01316.91
7.2.80.0100.00516.84
7.2.70.0060.00916.71
7.2.60.0110.00916.78
7.2.50.0110.00816.88
7.2.40.0050.01116.79
7.2.30.0040.00616.91
7.2.20.0090.00716.83
7.2.10.0100.00716.69
7.2.00.0060.00817.68
7.1.330.0000.01315.69
7.1.320.0080.00615.55
7.1.310.0000.01615.77
7.1.300.0070.00715.72
7.1.290.0060.00915.88
7.1.280.0070.00716.01
7.1.270.0030.00915.79
7.1.260.0120.00315.53
7.1.250.0030.01515.69
7.1.240.0070.00315.60
7.1.230.0090.00615.74
7.1.220.0130.00015.71
7.1.210.0060.00315.80
7.1.200.0030.00815.50
7.1.190.0100.00015.83
7.1.180.0070.00715.93
7.1.170.0070.00315.63
7.1.160.0120.00315.96
7.1.150.0030.01315.88
7.1.140.0070.00315.89
7.1.130.0000.01415.58
7.1.120.0060.00615.69
7.1.110.0000.01215.73
7.1.100.0040.00816.92
7.1.90.0030.00615.74
7.1.80.0110.00315.84
7.1.70.0050.00716.45
7.1.60.0130.00517.54
7.1.50.0060.01116.33
7.1.40.0000.01415.73
7.1.30.0060.00915.63
7.1.20.0070.00715.74
7.1.10.0030.00915.68
7.1.00.0070.03818.96
7.0.330.0000.01315.64
7.0.320.0030.00615.33
7.0.310.0090.00615.28
7.0.300.0100.00615.38
7.0.290.0090.00915.36
7.0.280.0060.01015.48
7.0.270.0030.00615.43
7.0.260.0030.01015.57
7.0.250.0030.01015.34
7.0.240.0080.00015.14
7.0.230.0040.00715.52
7.0.220.0000.01415.26
7.0.210.0000.01315.44
7.0.200.0130.00416.13
7.0.190.0030.00915.23
7.0.180.0040.01215.16
7.0.170.0060.00315.45
7.0.160.0040.01215.41
7.0.150.0060.00615.55
7.0.140.0090.03318.80
7.0.130.0160.00015.59
7.0.120.0090.00315.54
7.0.110.0040.00715.38
7.0.100.0060.00915.48
7.0.90.0030.00615.30
7.0.80.0030.00715.33
7.0.70.0150.00315.56
7.0.60.0140.03917.62
7.0.50.0000.03016.73
7.0.40.0100.04216.82
7.0.30.0080.02816.87
7.0.20.0160.04216.92
7.0.10.0070.02316.79
7.0.00.0070.04316.84
5.6.400.0070.00714.59
5.6.390.0040.00414.48
5.6.380.0000.01414.54
5.6.370.0000.01114.31
5.6.360.0060.01314.63
5.6.350.0090.00314.73
5.6.340.0080.00414.52
5.6.330.0030.00714.58
5.6.320.0000.01014.41
5.6.310.0060.00314.51
5.6.300.0040.00814.25
5.6.290.0000.01714.78
5.6.280.0060.03917.65
5.6.270.0030.01014.54
5.6.260.0000.00914.54
5.6.250.0100.00314.52
5.6.240.0060.00314.45
5.6.230.0090.00614.48
5.6.220.0070.01014.54
5.6.210.0030.05217.38
5.6.200.0070.04516.18
5.6.190.0050.02517.63
5.6.180.0180.04017.37
5.6.170.0110.02817.35
5.6.160.0070.04317.45
5.6.150.0020.02416.32
5.6.140.0090.02216.45
5.6.130.0100.03816.46
5.6.120.0050.04717.67
5.6.110.0060.02217.80
5.6.100.0100.04317.80
5.6.90.0060.02617.72
5.6.80.0100.03117.48
5.6.70.2180.02217.38
5.6.60.0060.00314.29
5.6.50.0080.00814.30
5.6.40.0070.00714.14
5.6.30.0000.01214.34
5.6.20.0030.00614.43
5.6.10.0110.00314.39
5.6.00.0060.00914.10
5.5.380.0030.00914.64
5.5.370.0100.00714.32
5.5.360.0070.00714.11
5.5.350.0090.02017.46
5.5.340.0090.04016.22
5.5.330.0040.02117.40
5.5.320.0250.02717.24
5.5.310.0180.04617.22
5.5.300.0130.02516.17
5.5.290.0060.04616.32
5.5.280.0070.04917.62
5.5.270.0070.04817.72
5.5.260.0080.03617.67
5.5.250.0060.04617.61
5.5.240.0100.04317.24
5.5.230.0000.01014.11
5.5.220.0100.00314.38
5.5.210.0030.01314.02
5.5.200.0090.00314.45
5.5.190.0050.00514.47
5.5.180.0060.00614.46
5.5.170.0060.00914.16
5.5.160.0030.00714.16
5.5.150.0040.00714.21
5.5.140.0000.01414.50
5.5.130.0090.00614.53
5.5.120.0030.00914.27
5.5.110.0090.00614.50
5.5.100.0030.01314.61
5.5.90.0040.01214.30
5.5.80.0000.01214.38
5.5.70.0070.00414.52
5.5.60.0030.01014.44
5.5.50.0090.00614.50
5.5.40.0070.00714.22
5.5.30.0060.00914.39
5.5.20.0090.00314.04
5.5.10.0030.00714.43
5.5.00.0090.00614.29
5.4.450.0280.03715.30
5.4.440.0380.04215.48
5.4.430.0350.02615.14
5.4.420.0420.03015.32
5.4.410.0300.03215.21
5.4.400.0090.02615.24
5.4.390.0480.03615.25
5.4.380.0300.03515.12
5.4.370.0220.02714.94
5.4.360.0120.03214.79
5.4.350.0170.03215.01
5.4.340.0230.03014.98
5.4.330.0030.00311.02
5.4.320.0070.02011.90
5.4.310.0040.02411.82
5.4.300.0050.02111.98
5.4.290.0060.02911.73
5.4.280.0040.02111.85
5.4.270.0080.01811.78
5.4.260.0040.02411.84
5.4.250.0040.02211.73
5.4.240.0080.01911.80
5.4.230.0010.02411.69
5.4.220.0060.02011.90
5.4.210.0040.02211.64
5.4.200.0040.02511.79
5.4.190.0050.02111.76
5.4.180.0060.01911.56
5.4.170.0080.01911.61
5.4.160.0040.03111.76
5.4.150.0060.02311.78
5.4.140.0020.03111.60
5.4.130.0050.02511.65
5.4.120.0070.02211.62
5.4.110.0040.02611.44
5.4.100.0060.02811.65
5.4.90.0080.02711.49
5.4.80.0050.02811.63
5.4.70.0080.01911.49
5.4.60.0070.02111.41
5.4.50.0060.02911.61
5.4.40.0030.03111.66
5.4.30.0080.01611.48
5.4.20.0090.02111.61
5.4.10.0070.01911.50
5.4.00.0060.02111.35
5.3.290.0060.02411.79
5.3.280.0040.02411.59
5.3.270.0040.02411.60
5.3.260.0040.02411.72
5.3.250.0040.02211.59
5.3.240.0050.02011.66
5.3.230.0030.02211.69
5.3.220.0070.02211.66
5.3.210.0100.02911.63
5.3.200.0040.04011.68
5.3.190.0050.02511.68
5.3.180.0050.02211.77
5.3.170.0020.02311.74
5.3.160.0050.02811.77
5.3.150.0040.02511.76
5.3.140.0090.02011.74
5.3.130.0050.02711.64
5.3.120.0040.03011.72
5.3.110.0040.03911.71
5.3.100.0070.03011.44
5.3.90.0070.02411.41
5.3.80.0050.02611.38
5.3.70.0070.03111.34
5.3.60.0100.02411.44
5.3.50.0100.02511.35
5.3.40.0050.02611.36
5.3.30.0050.02511.39
5.3.20.0070.02211.17
5.3.10.0020.02611.14
5.3.00.0030.02211.07
5.2.170.0040.0339.24
5.2.160.0030.0339.24
5.2.150.0070.0439.24
5.2.140.0070.0499.24
5.2.130.0070.0419.20
5.2.120.0060.0499.20
5.2.110.0020.0449.20
5.2.100.0060.0479.20
5.2.90.0060.0479.20
5.2.80.0050.0489.19
5.2.70.0040.0469.19
5.2.60.0070.0469.15
5.2.50.0040.0489.12
5.2.40.0080.0389.10
5.2.30.0070.0419.07
5.2.20.0060.0399.05
5.2.10.0040.0328.96
5.2.00.0060.0358.82
5.1.60.0030.0348.11
5.1.50.0030.0258.10
5.1.40.0030.0268.08
5.1.30.0040.0268.44
5.1.20.0030.0438.46
5.1.10.0060.0348.18
5.1.00.0050.0278.18
5.0.50.0040.0306.66
5.0.40.0060.0296.53
5.0.30.0080.0396.34
5.0.20.0050.0306.31
5.0.10.0050.0206.28
5.0.00.0040.0416.28
4.4.90.0020.0174.78
4.4.80.0040.0154.75
4.4.70.0060.0174.75
4.4.60.0040.0154.76
4.4.50.0040.0214.77
4.4.40.0070.0294.70
4.4.30.0040.0214.76
4.4.20.0060.0204.85
4.4.10.0020.0244.85
4.4.00.0040.0324.76
4.3.110.0040.0224.67
4.3.100.0030.0144.66
4.3.90.0020.0154.63
4.3.80.0010.0264.59
4.3.70.0010.0164.63
4.3.60.0000.0184.63
4.3.50.0030.0164.63
4.3.40.0030.0244.54
4.3.30.0020.0223.30
4.3.20.0020.0233.28
4.3.10.0030.0163.23
4.3.00.0030.01010.54

preferences:
43.03 ms | 400 KiB | 5 Q