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 V implements arrayaccess{ protected $array = array( 'arraykey' => 'arraykey2', 'arraykey2' => 'callback', ); function __invoke() { return function(){ $this->secret = "I beat the mammoth!"; }; } function __toString(){ return "arraykey"; } 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 V; // 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.70.0100.01018.68
8.3.60.0090.01218.68
8.3.50.0150.00522.11
8.3.40.0120.00918.82
8.3.30.0080.00619.04
8.3.20.0050.00320.39
8.3.10.0020.00521.96
8.3.00.0090.00022.43
8.2.190.0110.01116.95
8.2.180.0180.00417.00
8.2.170.0110.00422.96
8.2.160.0120.00920.22
8.2.150.0070.00724.18
8.2.140.0060.00924.66
8.2.130.0050.00226.16
8.2.120.0130.00719.36
8.2.110.0060.00322.25
8.2.100.0070.00719.64
8.2.90.0030.00519.09
8.2.80.0000.00818.04
8.2.70.0080.00017.63
8.2.60.0000.00817.93
8.2.50.0030.00518.07
8.2.40.0000.00918.34
8.2.30.0150.00018.00
8.2.20.0050.00517.80
8.2.10.0040.00417.85
8.2.00.0040.00417.84
8.1.280.0120.00925.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0070.00324.02
8.1.230.0000.01119.29
8.1.220.0040.00417.75
8.1.210.0000.00918.77
8.1.200.0000.00917.23
8.1.190.0040.00417.55
8.1.180.0030.00518.78
8.1.170.0040.00418.46
8.1.160.0050.00221.95
8.1.150.0030.00518.58
8.1.140.0000.00817.46
8.1.130.0000.00717.88
8.1.120.0000.00717.54
8.1.110.0080.00017.48
8.1.100.0000.00817.41
8.1.90.0080.00017.29
8.1.80.0000.00717.40
8.1.70.0070.00017.47
8.1.60.0090.00317.63
8.1.50.0080.00017.45
8.1.40.0050.00317.56
8.1.30.0000.00717.67
8.1.20.0030.00617.65
8.1.10.0000.00817.66
8.1.00.0000.00817.56
8.0.300.0040.00418.77
8.0.290.0030.00617.18
8.0.280.0000.00718.40
8.0.270.0030.00617.14
8.0.260.0000.00716.93
8.0.250.0050.00517.06
8.0.240.0050.00217.00
8.0.230.0070.00016.87
8.0.220.0030.00316.97
8.0.210.0070.00016.84
8.0.200.0030.00317.04
8.0.190.0040.00416.98
8.0.180.0070.00016.87
8.0.170.0080.00016.87
8.0.160.0040.00416.93
8.0.150.0000.00816.83
8.0.140.0000.00816.84
8.0.130.0060.00313.30
8.0.120.0030.00516.89
8.0.110.0050.00216.93
8.0.100.0040.00417.05
8.0.90.0000.00716.88
8.0.80.0140.00516.96
8.0.70.0040.00416.95
8.0.60.0040.00416.93
8.0.50.0050.00216.78
8.0.30.0120.00817.21
8.0.20.0130.01017.40
8.0.10.0000.00817.08
8.0.00.0060.01416.76
7.4.330.0000.00715.00
7.4.320.0060.00016.54
7.4.300.0030.00316.63
7.4.290.0040.00416.65
7.4.280.0000.00716.54
7.4.270.0070.00016.56
7.4.260.0040.00416.52
7.4.250.0020.00516.49
7.4.240.0030.00416.58
7.4.230.0070.00016.39
7.4.220.0060.01316.75
7.4.210.0060.00916.66
7.4.200.0040.00416.38
7.4.190.0000.00816.66
7.4.160.0100.00616.66
7.4.150.0140.00317.40
7.4.140.0100.00917.86
7.4.130.0110.00916.60
7.4.120.0110.00616.57
7.4.110.0090.00816.40
7.4.100.0140.00316.54
7.4.90.0150.00316.62
7.4.80.0110.01219.39
7.4.70.0080.00916.36
7.4.60.0090.00916.50
7.4.50.0050.00316.57
7.4.40.0060.01022.77
7.4.30.0090.00616.59
7.4.00.0030.01014.64
7.3.330.0060.00013.40
7.3.320.0000.00613.19
7.3.310.0030.00316.29
7.3.300.0030.00316.34
7.3.290.0070.01016.38
7.3.280.0080.00816.38
7.3.270.0030.01417.40
7.3.260.0160.01916.50
7.3.250.0100.01016.53
7.3.240.0120.00416.45
7.3.230.0070.01016.47
7.3.210.0100.00716.59
7.3.200.0090.00619.39
7.3.190.0090.01216.42
7.3.180.0100.00716.44
7.3.170.0090.00616.60
7.3.160.0150.00016.70
7.3.120.0120.00414.80
7.2.330.0110.00716.84
7.2.320.0060.01816.72
7.2.310.0070.01016.79
7.2.300.0090.00916.73
7.2.290.0070.01116.71
7.2.00.0030.01019.59
7.1.200.0140.00015.64
7.1.100.0060.00917.93
7.1.70.0030.00517.09
7.1.60.0140.01119.82
7.1.50.0130.01017.01
7.1.00.0030.07722.36
7.0.200.0000.00816.88
7.0.140.0030.07022.04
7.0.60.0130.08019.84
7.0.50.0030.04017.88
7.0.40.0100.09020.18
7.0.30.0330.05020.09
7.0.20.0130.04720.19
7.0.10.0270.03720.24
7.0.00.0030.04320.25
5.6.280.0100.07021.14
5.6.210.0030.08320.46
5.6.200.0100.08718.24
5.6.190.0030.05320.50
5.6.180.4100.04720.58
5.6.170.0230.06020.44
5.6.160.0070.05320.34
5.6.150.0100.08018.29
5.6.140.0130.05318.20
5.6.130.0070.05318.27
5.6.120.0130.08321.13
5.6.110.0100.08020.97
5.6.100.0030.08721.08
5.6.90.0070.08721.00
5.6.80.0130.06720.40
5.6.70.0270.08020.55
5.5.350.0100.06720.43
5.5.340.0000.06317.93
5.5.330.0070.09020.47
5.5.320.0200.08720.22
5.5.310.0300.06720.24
5.5.300.0000.04717.95
5.5.290.0000.04717.98
5.5.280.0130.08020.91
5.5.270.0030.06020.65
5.5.260.0100.04020.77
5.5.250.0070.04320.81
5.5.240.0200.05720.14
5.4.450.0430.06719.57
5.4.440.0500.06719.53
5.4.430.0130.05319.21
5.4.420.0070.06019.21
5.4.410.0100.05319.11
5.4.400.0830.00018.82
5.4.390.0770.00018.48
5.4.380.0230.05718.80
5.4.370.0330.05318.48
5.4.360.0300.04018.74
5.4.350.0370.05318.61
5.4.340.0270.06018.79
5.4.320.0070.03612.52
5.4.310.0090.04812.52
5.4.300.0120.04312.52
5.4.290.0040.04712.51
5.4.280.0070.04112.41
5.4.270.0130.07018.80
5.4.260.0070.05718.94
5.4.250.0100.05318.99
5.4.240.0130.05718.77
5.4.230.0200.04718.65
5.4.220.0170.04718.91
5.4.210.0100.05718.65
5.4.200.0170.05718.96
5.4.190.0100.08019.09
5.4.180.0170.05718.64
5.4.170.0300.05318.80
5.4.160.0070.07718.99
5.4.150.0100.06018.93
5.4.140.0100.07016.45
5.4.130.0030.05316.36
5.4.120.0130.05716.44
5.4.110.0030.06716.61
5.4.100.0030.06716.57
5.4.90.0100.06316.48
5.4.80.0200.06016.38
5.4.70.0100.04716.52
5.4.60.0130.06716.36
5.4.50.0070.04716.49
5.4.40.0030.06316.68
5.4.30.0030.05716.63
5.4.20.0170.06016.50
5.4.10.0100.06316.52
5.4.00.0100.05315.83
5.3.290.0060.04612.80
5.3.280.0130.05714.58
5.3.270.0100.05714.71
5.3.260.0070.06014.71
5.3.250.0070.07314.59
5.3.240.0100.06014.60
5.3.230.0200.06314.70
5.3.220.0070.05014.75
5.3.210.0100.07314.68
5.3.200.0130.05714.77
5.3.190.0100.05714.66
5.3.180.0100.06014.67
5.3.170.0230.03314.69
5.3.160.0130.05014.61
5.3.150.0030.05314.76
5.3.140.0100.07014.40
5.3.130.0170.04714.63
5.3.120.0100.07014.75
5.3.110.0130.05314.65
5.3.100.0200.06014.28
5.3.90.0070.05014.04
5.3.80.0100.07314.11
5.3.70.0200.05714.01
5.3.60.0030.06714.10
5.3.50.0100.05713.99
5.3.40.0170.05713.87
5.3.30.0030.07013.95
5.3.20.0000.08013.78
5.3.10.0100.06313.57
5.3.00.0070.05713.64
5.2.170.0100.07011.24
5.2.160.0100.06011.23
5.2.150.0070.04011.24
5.2.140.0230.06011.23
5.2.130.0030.05711.20
5.2.120.0100.03711.19
5.2.110.0170.04711.17
5.2.100.0130.04311.18
5.2.90.0070.06011.01
5.2.80.0070.05311.28
5.2.70.0070.05011.20
5.2.60.0100.05710.89
5.2.50.0030.04311.00
5.2.40.0030.05011.23
5.2.30.0030.04311.05
5.2.20.0100.04311.05
5.2.10.0070.04310.87
5.2.00.0030.04010.91
5.1.60.0000.05010.16
5.1.50.0070.03710.03
5.1.40.0100.03310.05
5.1.30.0030.05710.32
5.1.20.0000.04310.43
5.1.10.0100.03310.00
5.1.00.0070.04710.28
5.0.50.0130.0378.63
5.0.40.0030.0278.43
5.0.30.0070.0538.31
5.0.20.0030.0278.29
5.0.10.0000.0308.16
5.0.00.0100.0408.15
4.4.90.0000.0276.64
4.4.80.0030.0236.64
4.4.70.0000.0236.64
4.4.60.0070.0176.64
4.4.50.0000.0236.64
4.4.40.0030.0436.64
4.4.30.0030.0236.64
4.4.20.0030.0236.64
4.4.10.0000.0276.64
4.4.00.0030.0436.64
4.3.110.0000.0276.64
4.3.100.0070.0206.64
4.3.90.0030.0236.64
4.3.80.0070.0376.64
4.3.70.0070.0206.64
4.3.60.0030.0306.64
4.3.50.0030.0206.64
4.3.40.0100.0376.64
4.3.30.0070.0176.64
4.3.20.0000.0236.64
4.3.10.0070.0176.64
4.3.00.0000.0236.41

preferences:
39.17 ms | 401 KiB | 5 Q