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 $array = array( 'firstKey' => 'secondKey', 'secondKey' => 'callback', ); 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 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.0110.00318.43
8.3.50.0120.00921.98
8.3.40.0090.00618.82
8.3.30.0140.00019.07
8.3.20.0070.00020.07
8.3.10.0040.00422.09
8.3.00.0040.00422.27
8.2.180.0140.00717.00
8.2.170.0070.00722.96
8.2.160.0070.00720.23
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00319.36
8.2.110.0090.00022.11
8.2.100.0090.00317.91
8.2.90.0050.00319.35
8.2.80.0090.00017.97
8.2.70.0030.00617.75
8.2.60.0040.00418.03
8.2.50.0060.00318.07
8.2.40.0000.00818.16
8.2.30.0090.00018.05
8.2.20.0050.00317.70
8.2.10.0080.00019.59
8.2.00.0050.00317.80
8.1.280.0070.00725.92
8.1.270.0040.00422.11
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0060.00323.92
8.1.230.0090.00319.05
8.1.220.0100.00017.74
8.1.210.0080.00018.77
8.1.200.0060.00317.48
8.1.190.0090.00017.43
8.1.180.0040.00418.10
8.1.170.0030.00618.59
8.1.160.0000.00721.93
8.1.150.0040.00418.70
8.1.140.0040.00417.46
8.1.130.0040.00417.57
8.1.120.0040.00417.37
8.1.110.0060.00317.39
8.1.100.0000.00717.32
8.1.90.0060.00317.43
8.1.80.0040.00317.32
8.1.70.0040.00417.42
8.1.60.0030.00617.51
8.1.50.0050.00317.52
8.1.40.0030.00617.41
8.1.30.0070.00017.50
8.1.20.0040.00417.67
8.1.10.0000.00817.65
8.1.00.0080.00017.42
8.0.300.0040.00418.77
8.0.290.0040.00417.03
8.0.280.0070.00018.48
8.0.270.0040.00417.24
8.0.260.0000.00716.83
8.0.250.0000.00717.07
8.0.240.0050.00517.05
8.0.230.0040.00416.90
8.0.220.0080.00016.96
8.0.210.0000.00716.88
8.0.200.0080.00016.96
8.0.190.0000.00817.06
8.0.180.0070.00017.03
8.0.170.0000.00816.98
8.0.160.0040.00417.00
8.0.150.0060.00317.00
8.0.140.0050.00216.95
8.0.130.0050.00313.48
8.0.120.0030.00516.91
8.0.110.0000.00716.87
8.0.100.0040.00417.08
8.0.90.0000.00716.86
8.0.80.0100.01016.95
8.0.70.0030.00516.99
8.0.60.0000.00717.00
8.0.50.0050.00316.91
8.0.30.0080.01017.10
8.0.20.0070.01317.40
8.0.10.0000.00716.96
8.0.00.0120.01016.88
7.4.330.0060.00015.14
7.4.320.0000.00716.51
7.4.300.0000.00616.57
7.4.290.0000.00716.63
7.4.280.0000.00716.46
7.4.270.0030.00316.51
7.4.260.0000.00716.52
7.4.250.0000.00716.51
7.4.240.0040.00316.59
7.4.230.0030.00316.43
7.4.220.0150.00316.54
7.4.210.0050.01016.54
7.4.200.0070.00016.68
7.4.190.0040.00416.54
7.4.160.0120.00616.45
7.4.150.0140.01117.40
7.4.140.0080.01317.86
7.4.130.0130.00416.64
7.4.120.0100.00716.47
7.4.110.0150.00316.55
7.4.100.0070.01716.67
7.4.90.0060.01216.38
7.4.80.0150.00819.39
7.4.70.0080.00816.55
7.4.60.0080.00816.40
7.4.50.0080.00016.42
7.4.40.0030.01322.77
7.4.30.0120.00616.66
7.4.10.0070.01114.80
7.4.00.0080.00914.98
7.3.330.0000.00513.52
7.3.320.0050.00013.32
7.3.310.0020.00516.43
7.3.300.0000.00716.47
7.3.290.0110.00716.36
7.3.280.0090.00716.42
7.3.270.0070.01017.40
7.3.260.0120.00916.55
7.3.250.0080.00916.48
7.3.240.0130.00816.57
7.3.230.0140.00816.41
7.3.210.0100.00616.51
7.3.200.0120.00319.39
7.3.190.0040.01216.40
7.3.180.0070.00716.60
7.3.170.0070.01716.55
7.3.160.0060.01016.59
7.3.130.0060.00914.93
7.3.120.0080.00914.88
7.3.110.0060.01314.89
7.3.100.0040.01114.98
7.3.90.0090.00614.82
7.3.80.0060.00914.73
7.3.70.0000.01214.75
7.3.60.0040.01114.95
7.3.50.0070.00714.69
7.3.40.0000.01414.76
7.3.30.0030.01414.65
7.3.20.0070.01016.59
7.3.10.0120.00316.39
7.3.00.0070.00716.67
7.2.330.0120.00616.48
7.2.320.0140.01216.71
7.2.310.0130.00316.72
7.2.300.0150.00316.81
7.2.290.0060.01116.46
7.2.260.0040.00815.04
7.2.250.0080.00815.23
7.2.240.0030.01214.68
7.2.230.0060.01015.27
7.2.220.0100.01015.23
7.2.210.0030.00915.01
7.2.200.0030.00614.93
7.2.190.0060.01015.01
7.2.180.0040.01414.86
7.2.170.0000.02015.07
7.2.160.0090.00615.07
7.2.150.0030.00916.83
7.2.140.0030.01216.60
7.2.130.0060.00616.79
7.2.120.0130.00716.88
7.2.110.0100.01016.76
7.2.100.0110.00416.98
7.2.90.0100.01016.92
7.2.80.0040.01116.88
7.2.70.0090.00616.89
7.2.60.0050.00816.88
7.2.50.0060.00917.06
7.2.40.0050.00516.71
7.2.30.0060.01016.84
7.2.20.0000.00917.03
7.2.10.0000.01517.03
7.2.00.0020.01417.99
7.1.330.0030.01015.70
7.1.320.0120.00315.94
7.1.310.0030.01015.71
7.1.300.0150.00415.51
7.1.290.0100.00715.82
7.1.280.0140.00715.83
7.1.270.0030.01315.59
7.1.260.0040.00815.96
7.1.250.0040.01115.50
7.1.240.0060.01215.71
7.1.230.0050.00515.87
7.1.220.0040.01115.89
7.1.210.0060.00915.82
7.1.200.0040.00915.76
7.1.190.0030.01315.79
7.1.180.0000.01515.98
7.1.170.0040.01115.49
7.1.160.0060.00615.60
7.1.150.0040.00815.79
7.1.140.0100.00315.93
7.1.130.0070.00415.73
7.1.120.0000.01416.05
7.1.110.0030.01315.80
7.1.100.0070.00617.07
7.1.90.0090.00615.63
7.1.80.0090.00015.78
7.1.70.0030.00716.37
7.1.60.0070.00917.88
7.1.50.0100.00916.49
7.1.40.0030.01015.86
7.1.30.0070.00715.63
7.1.20.0070.00315.80
7.1.10.0070.01015.90
7.1.00.0020.04618.96
7.0.330.0040.01115.36
7.0.320.0030.00715.27
7.0.310.0090.00015.17
7.0.300.0070.00715.46
7.0.290.0000.00815.29
7.0.280.0000.01215.40
7.0.270.0100.00315.25
7.0.260.0060.00615.24
7.0.250.0040.00715.47
7.0.240.0060.00615.45
7.0.230.0030.01315.21
7.0.220.0040.00415.36
7.0.210.0040.00815.45
7.0.200.0030.00816.04
7.0.190.0100.00315.52
7.0.180.0060.00615.27
7.0.170.0030.01215.45
7.0.160.0080.00815.59
7.0.150.0100.00615.38
7.0.140.0030.03718.60
7.0.130.0070.00315.54
7.0.120.0040.01115.56
7.0.110.0060.00915.30
7.0.100.0050.05117.72
7.0.90.0100.03317.71
7.0.80.0080.04317.72
7.0.70.0130.02717.74
7.0.60.0150.02517.65
7.0.50.0130.04517.91
7.0.40.0030.03716.85
7.0.30.0050.03016.83
7.0.20.0050.02316.69
7.0.10.0110.03016.80
7.0.00.0090.02616.84
5.6.400.0030.01314.29
5.6.390.0130.00614.74
5.6.380.0030.00914.66
5.6.370.0070.01014.58
5.6.360.0130.00014.08
5.6.350.0000.01514.70
5.6.340.0060.00914.71
5.6.330.0070.00314.31
5.6.320.0040.01114.71
5.6.310.0070.00714.36
5.6.300.0040.01214.32
5.6.290.0040.01214.67
5.6.280.0020.04417.73
5.6.270.0110.00414.32
5.6.260.0030.01014.68
5.6.250.0070.04517.47
5.6.240.0130.03517.53
5.6.230.0050.03017.65
5.6.220.0050.04517.70
5.6.210.0120.04017.63
5.6.200.0150.03317.87
5.6.190.0100.02217.71
5.6.180.0100.03217.74
5.6.170.0070.03417.63
5.6.160.0030.02717.88
5.6.150.0020.02817.71
5.6.140.0070.04217.70
5.6.130.0030.02717.68
5.6.120.0020.04517.68
5.6.110.0050.04017.71
5.6.100.0090.04117.68
5.6.90.0090.04017.68
5.6.80.0110.03817.34
5.6.70.0070.02817.35
5.6.60.0080.03317.55
5.6.50.0040.04217.34
5.6.40.0050.04717.55
5.6.30.0080.03817.54
5.6.20.0120.03817.27
5.6.10.0050.04417.40
5.6.00.0080.02417.38
5.5.380.0110.03317.48
5.5.370.0030.02817.39
5.5.360.0100.04317.48
5.5.350.0100.04017.61
5.5.340.0070.04017.51
5.5.330.0050.02517.60
5.5.320.0070.04217.65
5.5.310.0080.04617.46
5.5.300.0070.04517.73
5.5.290.0060.02617.65
5.5.280.0100.03717.67
5.5.270.0030.04817.73
5.5.260.0090.04417.80
5.5.250.0100.02217.57
5.5.240.0080.04317.24
5.5.230.0050.04217.40
5.5.220.0080.04317.13
5.5.210.0110.03517.38
5.5.200.0060.04817.29
5.5.190.0120.03517.37
5.5.180.0120.03217.21
5.5.170.0040.00414.32
5.5.160.0070.03817.23
5.5.150.0110.04317.34
5.5.140.0080.04217.24
5.5.130.0060.03517.24
5.5.120.0070.04217.42
5.5.110.0070.04417.26
5.5.100.0070.04517.12
5.5.90.0020.04717.17
5.5.80.0000.03817.22
5.5.70.0040.04317.34
5.5.60.0050.04517.13
5.5.50.0090.02617.06
5.5.40.0030.03917.27
5.5.30.0080.03517.09
5.5.20.0050.04317.20
5.5.10.0050.04417.27
5.5.00.0030.04217.24
5.4.450.0070.04215.31
5.4.440.0050.04015.41
5.4.430.0070.03915.43
5.4.420.0040.04115.24
5.4.410.0070.04115.17
5.4.400.0050.03815.11
5.4.390.0090.03515.20
5.4.380.0080.03615.02
5.4.370.0050.03515.21
5.4.360.0020.04515.16
5.4.350.0050.03714.99
5.4.340.0100.03815.14
5.4.330.0060.00310.86
5.4.320.0020.02414.96
5.4.310.0070.04015.01
5.4.300.0080.03415.02
5.4.290.0050.04115.05
5.4.280.0040.03315.00
5.4.270.0050.03315.02
5.4.260.0080.03515.05
5.4.250.0080.04114.99
5.4.240.0030.04215.24
5.4.230.0020.04015.09
5.4.220.0020.03415.03
5.4.210.0090.03115.26
5.4.200.0050.03815.05
5.4.190.0050.03815.04
5.4.180.0080.03114.85
5.4.170.0050.04215.19
5.4.160.0030.04315.09
5.4.150.0090.04015.13
5.4.140.0050.02513.68
5.4.130.0020.04313.86
5.4.120.0040.02813.79
5.4.110.0040.03913.69
5.4.100.0020.04513.87
5.4.90.0030.03013.78
5.4.80.0000.03713.89
5.4.70.0080.01713.85
5.4.60.0030.02313.84
5.4.50.0110.02813.71
5.4.40.0070.03413.81
5.4.30.0030.04113.73
5.4.20.0080.02513.78
5.4.10.0070.02013.80
5.4.00.0060.03113.47
5.3.290.0030.04212.80
5.3.280.0110.04012.67
5.3.270.0010.02612.68
5.3.260.0070.04412.71
5.3.250.0150.02012.75
5.3.240.0110.03012.71
5.3.230.0030.04312.71
5.3.220.0070.03812.65
5.3.210.0080.03212.69
5.3.200.0050.04412.67
5.3.190.0040.03412.66
5.3.180.0030.04512.65
5.3.170.0030.04412.66
5.3.160.0030.03812.62
5.3.150.0050.03912.59
5.3.140.0020.03012.58
5.3.130.0120.02712.58
5.3.120.0030.03512.59
5.3.110.0070.04012.58
5.3.100.0080.02512.32
5.3.90.0030.03112.41
5.3.80.0040.04112.38
5.3.70.0080.03612.40
5.3.60.0040.03012.34
5.3.50.0100.03512.38
5.3.40.0020.04212.28
5.3.30.0050.02412.26
5.3.20.0020.02912.24
5.3.10.0080.03312.20
5.3.00.0030.03812.23
5.2.170.0070.06311.61
5.2.160.0100.05711.61
5.2.150.0100.05711.61
5.2.140.0030.05711.61
5.2.130.0030.06011.61
5.2.120.0030.06311.61
5.2.110.0030.04711.61
5.2.100.0030.05711.61
5.2.90.0070.06011.61
5.2.80.0100.04311.61
5.2.70.0030.06011.61
5.2.60.0070.03711.61
5.2.50.0000.05311.61
5.2.40.0030.06311.61
5.2.30.0070.04311.61
5.2.20.0030.03011.61
5.2.10.0100.04711.61
5.2.00.0070.05011.61
5.1.60.0030.04711.61
5.1.50.0000.05711.61
5.1.40.0000.03011.61
5.1.30.0030.05311.61
5.1.20.0000.03311.61
5.1.10.0070.03711.61
5.1.00.0030.06011.61
5.0.50.0030.04011.61
5.0.40.0000.02711.61
5.0.30.0030.05011.61
5.0.20.0030.04011.61
5.0.10.0030.04011.61
5.0.00.0030.03311.61
4.4.90.0070.03311.61
4.4.80.0030.01711.61
4.4.70.0000.03711.61
4.4.60.0000.04011.61
4.4.50.0000.03711.61
4.4.40.0030.03011.61
4.4.30.0030.03011.61
4.4.20.0000.03711.61
4.4.10.0070.03311.61
4.4.00.0030.05311.61
4.3.110.0000.02711.61
4.3.100.0000.01711.61
4.3.90.0030.02311.61
4.3.80.0030.04311.61
4.3.70.0070.02011.61
4.3.60.0070.03011.61
4.3.50.0030.02011.61
4.3.40.0030.04711.61
4.3.30.0030.03311.61
4.3.20.0030.01311.61
4.3.10.0000.03011.61
4.3.00.0000.03311.61

preferences:
59.96 ms | 401 KiB | 5 Q