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' , a()); //$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.0140.00016.63
8.3.50.0080.01121.93
8.3.40.0150.00319.07
8.3.30.0090.00619.07
8.3.20.0000.00820.25
8.3.10.0000.00721.91
8.3.00.0080.00019.50
8.2.180.0120.00616.60
8.2.170.0150.00022.96
8.2.160.0080.00620.36
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0090.00926.16
8.2.120.0000.00722.13
8.2.110.0070.00322.05
8.2.100.0060.00617.97
8.2.90.0030.00619.22
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0040.00418.05
8.2.50.0080.00018.07
8.2.40.0000.00919.88
8.2.30.0040.00418.17
8.2.20.0040.00417.88
8.2.10.0000.00818.11
8.2.00.0000.01017.90
8.1.280.0060.01225.92
8.1.270.0040.00424.02
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0040.00423.79
8.1.230.0080.00419.09
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0030.00617.38
8.1.190.0050.00317.55
8.1.180.0000.00918.10
8.1.170.0030.00618.57
8.1.160.0000.00822.11
8.1.150.0130.00018.68
8.1.140.0070.00017.48
8.1.130.0000.00717.77
8.1.120.0050.00317.41
8.1.110.0040.00417.51
8.1.100.0040.00417.50
8.1.90.0080.00017.55
8.1.80.0000.00817.48
8.1.70.0070.00017.42
8.1.60.0030.00617.64
8.1.50.0020.00517.59
8.1.40.0050.00317.45
8.1.30.0040.00417.57
8.1.20.0000.00817.66
8.1.10.0040.00417.47
8.1.00.0040.00417.43
8.0.300.0040.00418.77
8.0.290.0000.00717.16
8.0.280.0000.00718.36
8.0.270.0030.00317.20
8.0.260.0000.00617.17
8.0.250.0030.00317.02
8.0.240.0040.00417.10
8.0.230.0070.00017.05
8.0.220.0030.00317.02
8.0.210.0070.00016.98
8.0.200.0000.00716.94
8.0.190.0000.00817.07
8.0.180.0050.00316.89
8.0.170.0030.00517.04
8.0.160.0000.00716.95
8.0.150.0000.00716.84
8.0.140.0000.00816.90
8.0.130.0030.00313.45
8.0.120.0040.00416.94
8.0.110.0040.00416.99
8.0.100.0070.00016.84
8.0.90.0000.00717.01
8.0.80.0080.00817.00
8.0.70.0030.00516.81
8.0.60.0030.00516.87
8.0.50.0000.00717.02
8.0.30.0140.00517.03
8.0.20.0100.01017.40
8.0.10.0000.00716.91
8.0.00.0080.01116.80
7.4.330.0050.00015.14
7.4.320.0070.00016.56
7.4.300.0070.00016.68
7.4.290.0000.00716.56
7.4.280.0040.00416.61
7.4.270.0070.00016.54
7.4.260.0000.00716.58
7.4.250.0040.00416.41
7.4.240.0050.00316.56
7.4.230.0030.00316.37
7.4.220.0150.00316.61
7.4.210.0050.01016.59
7.4.200.0050.00316.45
7.4.190.0070.00016.56
7.4.160.0130.00316.70
7.4.150.0070.01017.40
7.4.140.0130.01017.86
7.4.130.0110.00816.56
7.4.120.0080.01016.63
7.4.110.0030.01416.56
7.4.100.0130.01016.59
7.4.90.0030.01416.72
7.4.80.0090.01319.39
7.4.70.0080.00916.53
7.4.60.0130.01116.73
7.4.50.0090.00016.64
7.4.40.0100.00722.77
7.4.30.0070.01016.57
7.4.00.0110.00414.94
7.3.330.0000.00613.30
7.3.320.0030.00313.27
7.3.310.0000.00716.49
7.3.300.0000.00716.33
7.3.290.0040.01116.43
7.3.280.0090.00916.40
7.3.270.0120.00617.40
7.3.260.0030.01416.49
7.3.250.0120.00616.51
7.3.240.0150.00616.69
7.3.230.0040.01416.66
7.3.210.0150.00616.64
7.3.200.0060.01016.45
7.3.190.0090.01316.61
7.3.180.0130.00316.69
7.3.170.0120.00416.74
7.3.160.0030.01316.44
7.3.120.0040.00714.68
7.2.330.0060.01216.77
7.2.320.0090.00916.82
7.2.310.0080.00816.85
7.2.300.0060.01016.77
7.2.290.0100.00716.61
7.2.60.0070.00716.58
7.2.00.0030.01219.29
7.1.200.0030.01015.98
7.1.100.0030.01018.16
7.1.70.0000.01117.30
7.1.60.0070.01719.46
7.1.50.0040.00716.99
7.1.00.0070.07022.57
7.0.200.0230.00416.75
7.0.140.0000.07321.93
7.0.60.0100.08319.93
7.0.50.0070.08017.91
7.0.40.0100.08320.15
7.0.30.0270.07320.11
7.0.20.0270.05320.13
7.0.10.0300.07720.02
7.0.00.0070.09020.23
5.6.280.0070.07021.09
5.6.210.0070.08020.69
5.6.200.0070.05018.26
5.6.190.0000.04720.67
5.6.180.0270.08020.50
5.6.170.0270.04020.48
5.6.160.0000.04720.44
5.6.150.0100.07018.18
5.6.140.0000.05018.10
5.6.130.0170.07718.15
5.6.120.0030.05021.00
5.6.110.0100.06021.03
5.6.100.0030.08321.00
5.6.90.0100.06321.02
5.6.80.0100.07720.39
5.6.70.0100.05720.38
5.5.350.0070.07020.31
5.5.340.0030.07717.95
5.5.330.0130.08320.37
5.5.320.0270.07720.35
5.5.310.0200.05020.26
5.5.300.0100.05317.93
5.5.290.0070.05318.08
5.5.280.0000.04320.79
5.5.270.0070.04720.77
5.5.260.0130.06720.77
5.5.250.0100.06320.73
5.5.240.0100.07720.30
5.4.450.1070.07019.63
5.4.440.0100.07019.18
5.4.430.0930.08319.54
5.4.420.0770.05319.18
5.4.410.0570.04719.22
5.4.400.0370.04718.84
5.4.390.0370.05719.27
5.4.380.0500.06018.74
5.4.370.0330.05318.59
5.4.360.0200.06318.71
5.4.350.0270.05718.63
5.4.340.0330.05018.62
5.4.320.0080.04412.52
5.4.310.0060.04112.51
5.4.300.0060.03512.52
5.4.290.0090.03712.50
5.4.280.0080.04612.39
5.4.270.0110.04512.39
5.4.260.0040.04112.39
5.4.250.0060.03912.39
5.4.240.0050.03912.39
5.4.230.0040.04112.39
5.4.220.0060.04412.39
5.4.210.0050.03712.38
5.4.200.0040.04012.39
5.4.190.0070.03512.38
5.4.180.0050.03712.38
5.4.170.0060.03612.39
5.4.160.0080.03412.38
5.4.150.0080.03612.39
5.4.140.0070.04412.07
5.4.130.0070.03512.05
5.4.120.0040.03612.02
5.4.110.0060.03512.00
5.4.100.0080.03312.01
5.4.90.0090.03612.01
5.4.80.0040.04312.01
5.4.70.0030.03812.01
5.4.60.0030.03712.00
5.4.50.0060.03612.00
5.4.40.0050.03711.98
5.4.30.0060.04311.99
5.4.20.0070.03911.99
5.4.10.0070.04011.99
5.4.00.0100.03611.48
5.3.290.0100.05112.80
5.3.280.0090.03912.71
5.3.270.0080.04212.72
5.3.260.0070.03912.72
5.3.250.0050.04212.71
5.3.240.0070.05112.72
5.3.230.0090.03612.71
5.3.220.0070.05512.68
5.3.210.0070.04412.68
5.3.200.0060.04612.68
5.3.190.0070.04312.68
5.3.180.0050.04212.68
5.3.170.0020.04112.67
5.3.160.0070.03612.68
5.3.150.0090.04312.68
5.3.140.0070.03612.66
5.3.130.0070.04012.65
5.3.120.0100.04712.66
5.3.110.0080.03812.65
5.3.100.0070.03612.13
5.3.90.0070.03612.11
5.3.80.0050.03712.11
5.3.70.0110.03912.11
5.3.60.0080.03912.11
5.3.50.0060.03512.04
5.3.40.0030.03912.04
5.3.30.0050.03512.00
5.3.20.0070.03411.79
5.3.10.0080.03211.74
5.3.00.0080.03411.73
5.2.170.0050.0349.24
5.2.160.0040.0319.24
5.2.150.0050.0309.24
5.2.140.0070.0399.23
5.2.130.0060.0419.20
5.2.120.0110.0369.20
5.2.110.0060.0409.20
5.2.100.0110.0439.20
5.2.90.0130.0349.20
5.2.80.0080.0299.20
5.2.70.0070.0289.20
5.2.60.0050.0429.16
5.2.50.0120.0369.13
5.2.40.0110.0389.10
5.2.30.0040.0349.07
5.2.20.0040.0319.05
5.2.10.0070.0288.96
5.2.00.0060.0288.83
5.1.60.0040.0258.11
5.1.50.0020.0288.11
5.1.40.0070.0248.09
5.1.30.0030.0278.44
5.1.20.0040.0278.45
5.1.10.0040.0288.18
5.1.00.0080.0388.18
5.0.50.0050.0216.66
5.0.40.0020.0256.53
5.0.30.0020.0336.34
5.0.20.0040.0206.30
5.0.10.0090.0186.28
5.0.00.0040.0396.27
4.4.90.0020.0214.78
4.4.80.0020.0164.76
4.4.70.0050.0214.76
4.4.60.0040.0154.75
4.4.50.0050.0154.77
4.4.40.0020.0274.71
4.4.30.0030.0164.76
4.4.20.0040.0144.84
4.4.10.0040.0174.84
4.4.00.0030.0254.76
4.3.110.0010.0184.67
4.3.100.0030.0164.66
4.3.90.0030.0224.63
4.3.80.0030.0334.59
4.3.70.0050.0204.63
4.3.60.0050.0204.63
4.3.50.0020.0174.63
4.3.40.0010.0264.54
4.3.30.0040.0143.30
4.3.20.0010.0173.28
4.3.10.0010.0173.24
4.3.00.0130.01310.54

preferences:
48.14 ms | 401 KiB | 5 Q