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 callback($test){ $func = function(){ $test->secret = "edef blah"; }; return $func->bindTo($test, 'Test'); } //$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.0070.00716.88
8.3.50.0130.01022.00
8.3.40.0100.00718.92
8.3.30.0110.00718.96
8.3.20.0000.00720.25
8.3.10.0050.00321.76
8.3.00.0080.00019.38
8.2.180.0130.00616.63
8.2.170.0090.00622.96
8.2.160.0100.00320.34
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0060.01226.16
8.2.120.0040.00422.09
8.2.110.0030.00622.24
8.2.100.0090.00317.97
8.2.90.0040.00419.39
8.2.80.0000.00818.05
8.2.70.0030.00517.75
8.2.60.0050.00318.04
8.2.50.0080.00018.07
8.2.40.0030.00620.07
8.2.30.0040.00418.03
8.2.20.0050.00317.77
8.2.10.0000.00718.03
8.2.00.0050.00517.88
8.1.280.0080.01225.92
8.1.270.0050.00323.83
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0040.00423.82
8.1.230.0080.00418.97
8.1.220.0050.00317.74
8.1.210.0080.00018.77
8.1.200.0060.00317.35
8.1.190.0050.00317.40
8.1.180.0000.00818.10
8.1.170.0040.00418.43
8.1.160.0000.00721.97
8.1.150.0030.00918.67
8.1.140.0040.00417.54
8.1.130.0040.00417.84
8.1.120.0000.00717.54
8.1.110.0040.00417.57
8.1.100.0040.00417.48
8.1.90.0040.00417.39
8.1.80.0040.00417.40
8.1.70.0000.00717.50
8.1.60.0030.00617.62
8.1.50.0090.00017.46
8.1.40.0050.00317.50
8.1.30.0000.00817.68
8.1.20.0000.00817.67
8.1.10.0060.00317.60
8.1.00.0040.00417.43
8.0.300.0030.00418.77
8.0.290.0000.00717.17
8.0.280.0030.00318.42
8.0.270.0030.00317.17
8.0.260.0000.00617.21
8.0.250.0000.00717.00
8.0.240.0050.00216.94
8.0.230.0050.00316.94
8.0.220.0030.00317.01
8.0.210.0030.00316.90
8.0.200.0000.00617.02
8.0.190.0070.00017.12
8.0.180.0000.00817.07
8.0.170.0040.00417.02
8.0.160.0000.00717.06
8.0.150.0000.00816.89
8.0.140.0000.00816.93
8.0.130.0030.00313.38
8.0.120.0000.00816.99
8.0.110.0050.00216.93
8.0.100.0050.00216.96
8.0.90.0000.00717.02
8.0.80.0110.01116.97
8.0.70.0000.00917.04
8.0.60.0040.00417.01
8.0.50.0040.00416.79
8.0.30.0120.00817.12
8.0.20.0090.00917.40
8.0.10.0000.00717.12
8.0.00.0080.01016.81
7.4.330.0000.00515.16
7.4.320.0000.00716.57
7.4.300.0030.00316.57
7.4.290.0070.00016.61
7.4.280.0030.00316.55
7.4.270.0040.00416.57
7.4.260.0000.00716.63
7.4.250.0080.00016.53
7.4.240.0030.00516.58
7.4.230.0000.00716.55
7.4.220.0120.00616.69
7.4.210.0100.00716.60
7.4.200.0080.00016.70
7.4.190.0070.00016.71
7.4.160.0040.01116.52
7.4.150.0100.00717.40
7.4.140.0120.00717.86
7.4.130.0150.00316.66
7.4.120.0110.00616.67
7.4.110.0040.01416.61
7.4.100.0150.00716.77
7.4.90.0100.00716.46
7.4.80.0130.00619.39
7.4.70.0150.00316.59
7.4.60.0110.00816.77
7.4.50.0040.00416.42
7.4.40.0070.01022.77
7.4.30.0110.00716.55
7.4.00.0100.00414.98
7.3.330.0000.00513.45
7.3.320.0030.00313.54
7.3.310.0040.00416.36
7.3.300.0030.00316.39
7.3.290.0090.00616.49
7.3.280.0150.00816.50
7.3.270.0130.00417.40
7.3.260.0090.00916.77
7.3.250.0120.00916.56
7.3.240.0070.01016.50
7.3.230.0030.01716.50
7.3.210.0150.00316.67
7.3.200.0100.00716.54
7.3.190.0110.00616.68
7.3.180.0120.00616.33
7.3.170.0060.00916.46
7.3.160.0130.00416.59
7.3.120.0050.01214.93
7.3.110.0060.01114.82
7.3.100.0050.00914.92
7.3.90.0030.00714.99
7.3.80.0060.00914.82
7.3.70.0060.00614.77
7.3.60.0050.00714.96
7.3.50.0020.00714.91
7.3.40.0070.00814.88
7.3.30.0040.00614.94
7.3.20.0120.00316.64
7.3.10.0060.00716.58
7.3.00.0100.00816.66
7.2.330.0160.00316.79
7.2.320.0060.01516.61
7.2.310.0060.01616.63
7.2.300.0100.00716.80
7.2.290.0060.01116.78
7.2.250.0060.01215.29
7.2.240.0040.01115.12
7.2.230.0050.00914.82
7.2.220.0080.00615.12
7.2.210.0050.00915.04
7.2.200.0040.00715.10
7.2.190.0100.00315.01
7.2.180.0050.01014.96
7.2.170.0070.00915.09
7.2.160.0080.00515.05
7.2.150.0070.01017.13
7.2.140.0030.01017.02
7.2.130.0030.01316.79
7.2.120.0090.00816.76
7.2.110.0100.00216.99
7.2.100.0100.00516.91
7.2.90.0080.00916.93
7.2.80.0110.00516.92
7.2.70.0120.00716.94
7.2.60.0050.00817.11
7.2.50.0060.00916.97
7.2.40.0080.00816.92
7.2.30.0050.01017.05
7.2.20.0080.00716.87
7.2.10.0100.00916.99
7.2.00.0080.01017.80
7.1.330.0090.00515.80
7.1.320.0090.00615.85
7.1.310.0080.00615.73
7.1.300.0060.00815.77
7.1.290.0060.00815.69
7.1.280.0020.00915.72
7.1.270.0070.00315.74
7.1.260.0040.01315.60
7.1.250.0020.01415.80
7.1.240.0100.00315.70
7.1.230.0030.00615.89
7.1.220.0060.00615.49
7.1.210.0060.00315.91
7.1.200.0140.00715.80
7.1.190.0110.00315.89
7.1.180.0120.00415.90
7.1.170.0090.00915.72
7.1.160.0090.00315.55
7.1.150.0000.01415.99
7.1.140.0150.00315.91
7.1.130.0100.00715.63
7.1.120.0100.01015.83
7.1.110.0030.00815.98
7.1.100.0040.00816.71
7.1.90.0060.00315.73
7.1.80.0180.00015.88
7.1.70.0020.00916.65
7.1.60.0090.01117.58
7.1.50.0060.01116.18
7.1.40.0070.00715.76
7.1.30.0030.00715.80
7.1.20.0030.00915.52
7.1.10.0100.00315.68
7.1.00.0050.04319.05
7.0.330.0040.00715.35
7.0.320.0060.01015.62
7.0.310.0060.00615.44
7.0.300.0080.00815.43
7.0.290.0140.00315.12
7.0.280.0000.00915.48
7.0.270.0030.01015.13
7.0.260.0030.00615.39
7.0.250.0090.00315.48
7.0.240.0170.00015.38
7.0.230.0060.00615.21
7.0.220.0060.00615.54
7.0.210.0030.00615.32
7.0.200.0110.00915.99
7.0.190.0040.01115.15
7.0.180.0070.00715.56
7.0.170.0110.00415.24
7.0.160.0100.00715.42
7.0.150.0080.00815.32
7.0.140.0070.03718.64
7.0.130.0110.00315.23
7.0.120.0070.00415.43
7.0.110.0050.00515.27
7.0.100.0070.01115.27
7.0.90.0060.00915.51
7.0.80.0030.00715.36
7.0.70.0090.00315.47
7.0.60.0050.03017.79
7.0.50.0050.04216.74
7.0.40.0030.02716.85
7.0.30.0160.02516.75
7.0.20.0210.03516.76
7.0.10.0100.04316.62
7.0.00.0020.05416.79
5.6.380.0030.01014.60
5.6.370.0080.00414.21
5.6.360.0030.01014.36
5.6.350.0030.01214.61
5.6.340.0070.00714.25
5.6.330.0080.00814.43
5.6.320.0030.00514.63
5.6.310.0100.00314.66
5.6.300.0000.00814.61
5.6.290.0060.01014.73
5.6.280.0030.01014.31
5.6.270.0040.00414.22
5.6.260.0060.00914.52
5.6.250.0130.00314.43
5.6.240.0040.00814.41
5.6.230.0060.01014.32
5.6.220.0070.00714.71
5.6.210.0090.04417.63
5.6.200.0120.04116.26
5.6.190.0090.04717.54
5.6.180.0180.04117.34
5.6.170.0080.02917.57
5.6.160.0030.05217.46
5.6.150.0050.02416.23
5.6.140.0030.02516.33
5.6.130.0080.02816.13
5.6.120.0030.04617.74
5.6.110.0030.03617.60
5.6.100.0090.04517.73
5.6.90.0100.04517.74
5.6.80.0120.04217.33
5.6.70.2380.02017.52
5.6.60.0100.00714.07
5.6.50.0070.00714.16
5.6.40.0040.01214.26
5.6.30.0030.01314.66
5.6.20.0150.00014.25
5.6.10.0090.00614.11
5.6.00.0080.00614.48
5.5.380.0060.00611.29
5.5.370.0030.00911.07
5.5.360.0040.00811.43
5.5.350.0110.02515.72
5.5.340.0080.02814.50
5.5.330.0060.02415.82
5.5.320.0130.02715.83
5.5.310.0130.04415.60
5.5.300.0060.02314.73
5.5.290.0090.04514.68
5.5.280.0030.03716.14
5.5.270.0050.04516.01
5.5.260.0100.04016.04
5.5.250.0060.04516.00
5.5.240.1820.02115.70
5.5.230.0030.01111.28
5.5.220.0030.00311.35
5.5.210.0030.00311.40
5.5.200.0080.00411.16
5.5.190.0060.00611.25
5.5.180.0100.00311.43
5.5.170.0060.00311.04
5.5.160.0030.00711.39
5.5.150.0060.00311.16
5.5.140.0060.00611.43
5.5.130.0040.00811.35
5.5.120.0090.00311.28
5.5.110.0060.00611.10
5.5.100.0070.00411.18
5.5.90.0080.00011.22
5.5.80.0030.00711.09
5.5.70.0050.00511.21
5.5.60.0040.00411.13
5.5.50.0110.00011.34
5.5.40.0090.00311.08
5.5.30.0090.00311.10
5.5.20.0000.01011.20
5.5.10.0060.00611.19
5.5.00.0060.00611.18
5.4.450.0380.03915.51
5.4.440.0390.03715.38
5.4.430.0000.03715.30
5.4.420.0430.03515.50
5.4.410.0320.03915.45
5.4.400.0510.03015.17
5.4.390.0090.03615.04
5.4.380.0160.03314.91
5.4.370.0460.03414.76
5.4.360.0180.03214.76
5.4.350.0180.03714.94
5.4.340.0240.04014.99
5.4.330.0150.00410.97
5.4.320.0060.02611.70
5.4.310.0030.02911.81
5.4.300.0090.02111.79
5.4.290.0050.03111.87
5.4.280.0100.02711.73
5.4.270.0070.02611.84
5.4.260.0100.02511.76
5.4.250.0080.02311.63
5.4.240.0070.02011.84
5.4.230.0070.02311.75
5.4.220.0050.02511.72
5.4.210.0070.02211.56
5.4.200.0080.02611.83
5.4.190.0040.02811.70
5.4.180.0100.02211.78
5.4.170.0060.02711.83
5.4.160.0100.01911.88
5.4.150.0080.02411.79
5.4.140.0030.03011.72
5.4.130.0090.02111.40
5.4.120.0060.02211.61
5.4.110.0030.02411.54
5.4.100.0070.02211.59
5.4.90.0050.02411.61
5.4.80.0050.02511.58
5.4.70.0100.02311.48
5.4.60.0060.03111.44
5.4.50.0050.02311.60
5.4.40.0020.02611.61
5.4.30.0060.02011.64
5.4.20.0040.02411.41
5.4.10.0050.02311.58
5.4.00.0050.02211.27
5.3.290.0060.02411.79
5.3.280.0090.02111.65
5.3.270.0050.03111.69
5.3.260.0100.01811.59
5.3.250.0060.02211.70
5.3.240.0070.02111.66
5.3.230.0100.02211.67
5.3.220.0090.02111.56
5.3.210.0090.02211.47
5.3.200.0110.02811.62
5.3.190.0100.02611.62
5.3.180.0040.03311.74
5.3.170.0070.03211.72
5.3.160.0070.02411.71
5.3.150.0070.02011.72
5.3.140.0040.02411.49
5.3.130.0080.02111.64
5.3.120.0080.02111.69
5.3.110.0060.02211.67
5.3.100.0060.02211.44
5.3.90.0040.02211.45
5.3.80.0020.02311.30
5.3.70.0050.02211.30
5.3.60.0060.02211.41
5.3.50.0030.02411.27
5.3.40.0040.02211.23
5.3.30.0020.02311.33
5.3.20.0020.02311.19
5.3.10.0060.02610.95
5.3.00.0040.02411.04
5.2.170.0050.0189.33
5.2.160.0030.0199.35
5.2.150.0010.0219.16
5.2.140.0020.0189.29
5.2.130.0040.0159.27
5.2.120.0060.0289.26
5.2.110.0040.0249.11
5.2.100.0060.0239.16
5.2.90.0030.0249.25
5.2.80.0030.0219.21
5.2.70.0070.0159.15
5.2.60.0050.0169.15
5.2.50.0010.0219.11
5.2.40.0030.0199.19
5.2.30.0030.0199.16
5.2.20.0030.0189.06
5.2.10.0080.0169.06
5.2.00.0020.0198.73
5.1.60.0050.0148.18
5.1.50.0040.0138.29
5.1.40.0020.0238.29
5.1.30.0050.0158.39
5.1.20.0030.0178.44
5.1.10.0040.0188.26
5.1.00.0070.0188.22
5.0.50.0020.0167.46
5.0.40.0050.0107.39
5.0.30.0020.0197.30
5.0.20.0010.0147.28
5.0.10.0040.0127.27
5.0.00.0050.0167.27
4.4.90.0020.0126.52
4.4.80.0040.0116.50
4.4.70.0060.0096.50
4.4.60.0040.0096.51
4.4.50.0030.0086.51
4.4.40.0020.0166.48
4.4.30.0030.0096.51
4.4.20.0040.0096.55
4.4.10.0040.0096.55
4.4.00.0050.0126.50
4.3.110.0020.0096.46
4.3.100.0030.0096.46
4.3.90.0020.0136.45
4.3.80.0030.0136.42
4.3.70.0020.0106.44
4.3.60.0020.0106.44
4.3.50.0010.0116.44
4.3.40.0030.0156.39
4.3.30.0020.0135.78
4.3.20.0030.0095.77
4.3.10.0020.0115.74
4.3.00.0070.0099.40

preferences:
53.47 ms | 401 KiB | 5 Q