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 4. No redefining $test 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 class MyClass implements arrayaccess{ public $closure; public function __construct($test){ $this->closure = function(){ echo 'nearly there! just need to reshuffle the letters now, can set secret too as its not in scope.'; }; $this->closure = $this->closure->bindTo($test); // I dont really understand what this is doing } public function __toString(){ // Object of class V could not be converted to string; return 'firstKey'; } // array access stuff below was copied and pasted from http://www.php.net/manual/en/class.arrayaccess.php public $array = array( 'firstKey' => 'secondKey', 'secondKey' => 'callback', ); public function offsetSet($offset, $value) { if (is_null($offset)) { $this->array[] = $value; } else { $this->array[$offset] = $value; } } public function offsetExists($offset) { return isset($this->array[$offset]); } public function offsetUnset($offset) { unset($this->array[$offset]); } public function offsetGet($offset) { $offset = (string) $offset; return isset($this->array[$offset]) ? $this->array[$offset] : null; } } $test->callback = new MyClass($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.0070.00718.55
8.3.50.0100.00921.90
8.3.40.0180.00418.79
8.3.30.0150.00019.04
8.3.20.0040.00420.07
8.3.10.0040.00421.96
8.3.00.0050.00322.39
8.2.180.0140.00716.38
8.2.170.0170.00322.96
8.2.160.0130.00320.35
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0040.00419.48
8.2.110.0030.00622.27
8.2.100.0120.00019.57
8.2.90.0040.00419.36
8.2.80.0030.00518.03
8.2.70.0050.00317.75
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0000.00818.22
8.2.30.0000.00717.99
8.2.20.0070.00017.85
8.2.10.0000.00819.65
8.2.00.0040.00417.87
8.1.280.0120.00325.92
8.1.270.0050.00322.08
8.1.260.0050.00226.35
8.1.250.0040.00428.09
8.1.240.0050.00323.91
8.1.230.0070.00419.16
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0060.00317.25
8.1.190.0040.00417.53
8.1.180.0050.00518.10
8.1.170.0060.00318.59
8.1.160.0060.00322.03
8.1.150.0000.00718.66
8.1.140.0000.00817.40
8.1.130.0000.00717.76
8.1.120.0020.00517.41
8.1.110.0040.00417.36
8.1.100.0000.00717.50
8.1.90.0030.00617.45
8.1.80.0000.00717.50
8.1.70.0050.00217.48
8.1.60.0060.00317.60
8.1.50.0040.00417.52
8.1.40.0000.00817.53
8.1.30.0000.00817.66
8.1.20.0040.00417.64
8.1.10.0040.00417.48
8.1.00.0000.00717.52
8.0.300.0070.00018.77
8.0.290.0030.00517.15
8.0.280.0030.00318.37
8.0.270.0030.00317.23
8.0.260.0030.00316.77
8.0.250.0000.00717.01
8.0.240.0040.00417.04
8.0.230.0000.00816.93
8.0.220.0050.00316.97
8.0.210.0040.00416.86
8.0.200.0030.00317.07
8.0.190.0000.00816.95
8.0.180.0050.00317.03
8.0.170.0030.00516.89
8.0.160.0040.00416.89
8.0.150.0070.00016.87
8.0.140.0000.00716.94
8.0.130.0060.00013.42
8.0.120.0030.00516.84
8.0.110.0070.00016.86
8.0.100.0000.00716.94
8.0.90.0040.00416.84
8.0.80.0060.01116.95
8.0.70.0000.00717.05
8.0.60.0030.00516.96
8.0.50.0050.00316.82
8.0.30.0070.01117.36
8.0.20.0080.01117.40
8.0.10.0040.00417.14
8.0.00.0110.01316.78
7.4.330.0040.00415.00
7.4.320.0030.00316.54
7.4.300.0020.00516.46
7.4.290.0030.00316.66
7.4.280.0030.00316.61
7.4.270.0000.00816.58
7.4.260.0040.00416.52
7.4.250.0040.00416.48
7.4.240.0020.00616.47
7.4.230.0000.00616.36
7.4.220.0100.00716.64
7.4.210.0100.00616.61
7.4.200.0000.00716.38
7.4.190.0020.00516.39
7.4.160.0110.00516.58
7.4.150.0110.00717.40
7.4.140.0170.00717.86
7.4.130.0140.00516.56
7.4.120.0090.00816.62
7.4.110.0070.01016.66
7.4.100.0060.01216.55
7.4.90.0120.00616.53
7.4.80.0030.01519.39
7.4.70.0150.00816.64
7.4.60.0030.01316.54
7.4.50.0030.00616.52
7.4.40.0090.00622.77
7.4.30.0030.01416.30
7.4.10.0040.01514.95
7.4.00.0100.00514.97
7.3.330.0000.00513.40
7.3.320.0050.00013.45
7.3.310.0000.00816.44
7.3.300.0030.00316.31
7.3.290.0130.00016.38
7.3.280.0080.01016.38
7.3.270.0070.01017.40
7.3.260.0080.00816.34
7.3.250.0100.00916.50
7.3.240.0150.00616.45
7.3.230.0140.00916.63
7.3.210.0100.00716.62
7.3.200.0060.01019.39
7.3.190.0090.00916.52
7.3.180.0000.01516.53
7.3.170.0170.00616.59
7.3.160.0120.00316.65
7.3.130.0100.00714.74
7.3.120.0070.00714.97
7.3.110.0090.00615.02
7.3.100.0040.01114.98
7.3.90.0030.01014.89
7.3.80.0090.00614.75
7.3.70.0100.00714.50
7.3.60.0070.00714.92
7.3.50.0040.00714.71
7.3.40.0040.01214.87
7.3.30.0030.00614.74
7.3.20.0050.00516.55
7.3.10.0120.00316.47
7.3.00.0110.00416.38
7.2.330.0090.00916.80
7.2.320.0060.01816.69
7.2.310.0000.01816.93
7.2.300.0070.01016.76
7.2.290.0100.00716.77
7.2.260.0110.00815.01
7.2.250.0110.00715.18
7.2.240.0040.01215.12
7.2.230.0030.00714.97
7.2.220.0100.00715.05
7.2.210.0100.00315.03
7.2.200.0090.00614.95
7.2.190.0100.00315.25
7.2.180.0040.00714.93
7.2.170.0100.00615.09
7.2.160.0070.00315.13
7.2.150.0130.00317.18
7.2.140.0100.00016.76
7.2.130.0050.00916.68
7.2.120.0100.00716.59
7.2.110.0030.01316.58
7.2.100.0090.00716.82
7.2.90.0140.00916.64
7.2.80.0170.00516.91
7.2.70.0190.00216.88
7.2.60.0080.01016.99
7.2.50.0120.00516.97
7.2.40.0100.00816.86
7.2.30.0100.00916.90
7.2.20.0130.00516.88
7.2.10.0070.00716.69
7.2.00.0080.00617.62
7.1.330.0060.00615.93
7.1.320.0070.00715.85
7.1.310.0050.00815.80
7.1.300.0050.00315.98
7.1.290.0090.00316.00
7.1.280.0000.01515.82
7.1.270.0030.00715.53
7.1.260.0040.00715.99
7.1.250.0090.00615.85
7.1.240.0070.00715.56
7.1.230.0030.00915.91
7.1.220.0070.00715.94
7.1.210.0070.00715.85
7.1.200.0050.00615.65
7.1.190.0000.01215.87
7.1.180.0030.00915.66
7.1.170.0040.01215.57
7.1.160.0040.00915.73
7.1.150.0000.01415.86
7.1.140.0140.00015.86
7.1.130.0030.00915.68
7.1.120.0100.00715.84
7.1.110.0090.00615.96
7.1.100.0070.00817.14
7.1.90.0040.01115.86
7.1.80.0120.00415.83
7.1.70.0030.00616.50
7.1.60.0050.01517.87
7.1.50.0070.01216.41
7.1.40.0030.01015.83
7.1.30.0030.00715.68
7.1.20.0000.01315.91
7.1.10.0070.01015.72
7.1.00.0050.04018.98
7.0.330.0040.00715.57
7.0.320.0060.00615.32
7.0.310.0080.00315.52
7.0.300.0090.00315.46
7.0.290.0000.01415.57
7.0.280.0100.00315.46
7.0.270.0090.00615.46
7.0.260.0080.00415.07
7.0.250.0070.00415.47
7.0.240.0000.01015.30
7.0.230.0040.00815.33
7.0.220.0060.00615.30
7.0.210.0040.00815.50
7.0.200.0080.00516.07
7.0.190.0080.00615.52
7.0.180.0060.01015.48
7.0.170.0060.00315.47
7.0.160.0030.00615.18
7.0.150.0110.00315.50
7.0.140.0050.04118.59
7.0.130.0110.00015.42
7.0.120.0090.00615.52
7.0.110.0030.01015.23
7.0.100.0030.01415.14
7.0.90.0000.00915.59
7.0.80.0100.00315.18
7.0.70.0040.00815.15
7.0.60.0090.04617.63
7.0.50.0070.04216.75
7.0.40.0060.02816.71
7.0.30.0180.04116.80
7.0.20.0120.04916.75
7.0.10.0170.02916.80
7.0.00.0080.04216.82
5.6.400.0000.01314.39
5.6.390.0030.01414.35
5.6.380.0070.00714.49
5.6.370.0050.00514.56
5.6.360.0070.00714.43
5.6.350.0040.01114.55
5.6.340.0000.01614.36
5.6.330.0070.00714.16
5.6.320.0090.00614.23
5.6.310.0110.00414.24
5.6.300.0030.01014.59
5.6.290.0070.00714.47
5.6.280.0040.03917.58
5.6.270.0070.01014.52
5.6.260.0000.01114.20
5.6.250.0030.01014.70
5.6.240.0030.01014.29
5.6.230.0030.00914.55
5.6.220.0000.01114.45
5.6.210.0050.05017.49
5.6.200.0050.02316.26
5.6.190.0100.02017.57
5.6.180.1630.02217.49
5.6.170.0150.04217.52
5.6.160.0040.03417.60
5.6.150.0030.04516.34
5.6.140.0050.04616.18
5.6.130.0160.03916.30
5.6.120.0130.04017.69
5.6.110.0100.01817.82
5.6.100.0070.02517.83
5.6.90.0050.02417.61
5.6.80.0060.04317.31
5.6.70.0250.03817.32
5.6.60.0100.00714.24
5.6.50.0100.00614.26
5.6.40.0030.01414.29
5.6.30.0060.00614.64
5.6.20.0050.00814.55
5.6.10.0110.00714.36
5.6.00.0070.00714.42
5.5.380.0060.00614.58
5.5.370.0060.00614.64
5.5.360.0030.01014.42
5.5.350.0030.02617.42
5.5.340.0060.02216.22
5.5.330.0080.02617.33
5.5.320.0200.03717.31
5.5.310.0180.02717.24
5.5.300.0080.02016.15
5.5.290.0050.03016.19
5.5.280.0070.03217.40
5.5.270.0060.04217.53
5.5.260.0140.03917.69
5.5.250.0020.02717.47
5.5.240.0040.02417.28
5.5.230.0070.00714.49
5.5.220.0030.00914.59
5.5.210.0070.01014.43
5.5.200.0100.00714.01
5.5.190.0030.01014.45
5.5.180.0000.01414.04
5.5.170.0060.00914.35
5.5.160.0110.00013.91
5.5.150.0030.01214.39
5.5.140.0000.01314.36
5.5.130.0030.01314.27
5.5.120.0060.00613.84
5.5.110.0040.01214.22
5.5.100.0040.01114.27
5.5.90.0000.01314.03
5.5.80.0060.00914.15
5.5.70.0030.00914.19
5.5.60.0070.00714.61
5.5.50.0080.00814.45
5.5.40.0150.00014.62
5.5.30.0030.01314.03
5.5.20.0040.00814.15
5.5.10.0070.00714.39
5.5.00.0100.00314.24
5.4.450.0350.03916.10
5.4.440.0090.03115.95
5.4.430.0070.03015.93
5.4.420.0120.02816.02
5.4.410.0100.02815.97
5.4.400.0430.00315.66
5.4.390.0360.00415.56
5.4.380.0170.02915.64
5.4.370.0120.02715.65
5.4.360.0040.03415.64
5.4.350.0130.02715.66
5.4.340.0070.03015.65
5.4.330.0080.00312.50
5.4.320.0040.02112.51
5.4.310.0090.01812.51
5.4.300.0050.01912.51
5.4.290.0020.02212.51
5.4.280.0070.01912.46
5.4.270.0100.04015.72
5.4.260.0080.02615.63
5.4.250.0070.03515.75
5.4.240.0070.04515.65
5.4.230.0060.03315.72
5.4.220.0100.03215.65
5.4.210.0080.04315.57
5.4.200.0120.03915.73
5.4.190.0040.04315.76
5.4.180.0100.03015.74
5.4.170.0120.03015.75
5.4.160.0090.03615.66
5.4.150.0070.03015.79
5.4.140.0080.03514.47
5.4.130.0080.03614.58
5.4.120.0090.02814.55
5.4.110.0040.04214.54
5.4.100.0110.03614.53
5.4.90.0100.02914.47
5.4.80.0050.02714.51
5.4.70.0090.03014.47
5.4.60.0080.03314.48
5.4.50.0060.03814.53
5.4.40.0080.02814.55
5.4.30.0090.03014.51
5.4.20.0030.03514.50
5.4.10.0090.03214.52
5.4.00.0080.02814.18
5.3.290.0040.02312.65
5.3.280.0100.02813.60
5.3.270.0080.03013.61
5.3.260.0080.04013.52
5.3.250.0050.03513.55
5.3.240.0100.03613.48
5.3.230.0120.03513.59
5.3.220.0050.03413.59
5.3.210.0090.04013.59
5.3.200.0110.03713.55
5.3.190.0100.02913.53
5.3.180.0050.03713.57
5.3.170.0050.03213.54
5.3.160.0040.03313.53
5.3.150.0050.03513.55
5.3.140.0120.02913.65
5.3.130.0080.03913.57
5.3.120.0090.04013.54
5.3.110.0080.03113.54
5.3.100.0080.03813.23
5.3.90.0040.03213.27
5.3.80.0030.03013.31
5.3.70.0100.03113.26
5.3.60.0100.03413.30
5.3.50.0060.03313.28
5.3.40.0100.03513.28
5.3.30.0030.03013.13
5.3.20.0050.03813.16
5.3.10.0100.03613.11
5.3.00.0180.02813.12
5.2.170.0130.03711.25
5.2.160.0100.05711.23
5.2.150.0100.04011.22
5.2.140.0100.04011.10
5.2.130.0100.05011.20
5.2.120.0100.03311.29
5.2.110.0100.05311.29
5.2.100.0100.05311.17
5.2.90.0070.03711.18
5.2.80.0100.05311.32
5.2.70.0030.04311.06
5.2.60.0030.04711.28
5.2.50.0100.05011.00
5.2.40.0070.04711.08
5.2.30.0170.03711.17
5.2.20.0070.04310.95
5.2.10.0100.04310.82
5.2.00.0030.04310.91
5.1.60.0070.0379.85
5.1.50.0070.04010.10
5.1.40.0130.04010.19
5.1.30.0000.04310.43
5.1.20.0000.04710.27
5.1.10.0130.03310.17
5.1.00.0100.04010.10
5.0.50.0100.0238.48
5.0.40.0030.0278.43
5.0.30.0000.0538.19
5.0.20.0030.0338.27
5.0.10.0030.0278.27
5.0.00.0100.0438.01
4.4.90.0070.0176.72
4.4.80.0030.0276.72
4.4.70.0000.0236.72
4.4.60.0100.0206.72
4.4.50.0030.0206.72
4.4.40.0070.0436.72
4.4.30.0030.0236.72
4.4.20.0030.0306.72
4.4.10.0030.0276.72
4.4.00.0030.0376.72
4.3.110.0030.0236.72
4.3.100.0070.0206.72
4.3.90.0070.0206.72
4.3.80.0000.0406.72
4.3.70.0000.0236.72
4.3.60.0030.0236.72
4.3.50.0030.0236.72
4.3.40.0030.0506.72
4.3.30.0000.0276.72
4.3.20.0030.0276.72
4.3.10.0000.0306.72
4.3.00.0000.0236.54

preferences:
43.54 ms | 401 KiB | 5 Q