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) { 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.60.0090.00618.68
8.3.50.0120.00722.04
8.3.40.0000.01518.67
8.3.30.0120.00319.04
8.3.20.0040.00420.30
8.3.10.0070.00021.97
8.3.00.0100.00322.38
8.2.180.0160.00616.63
8.2.170.0120.00322.96
8.2.160.0080.01220.43
8.2.150.0070.00724.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0080.00019.48
8.2.110.0090.00022.23
8.2.100.0110.00017.84
8.2.90.0000.00819.41
8.2.80.0040.00718.05
8.2.70.0050.00317.63
8.2.60.0080.00017.80
8.2.50.0000.00818.07
8.2.40.0080.00418.34
8.2.30.0060.00618.23
8.2.20.0040.00417.75
8.2.10.0040.00417.72
8.2.00.0050.00317.82
8.1.280.0120.00625.92
8.1.270.0040.00423.96
8.1.260.0070.00726.35
8.1.250.0090.00628.09
8.1.240.0050.00523.92
8.1.230.0070.00418.96
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0000.00817.52
8.1.180.0000.00818.70
8.1.170.0080.00018.59
8.1.160.0030.00522.04
8.1.150.0060.00318.79
8.1.140.0040.00417.54
8.1.130.0030.00317.78
8.1.120.0040.00417.57
8.1.110.0040.00417.38
8.1.100.0000.00817.40
8.1.90.0000.00717.44
8.1.80.0000.00717.41
8.1.70.0050.00317.52
8.1.60.0060.00617.68
8.1.50.0040.00417.58
8.1.40.0040.00417.50
8.1.30.0050.00217.67
8.1.20.0080.00017.68
8.1.10.0000.00717.49
8.1.00.0050.00217.60
8.0.300.0020.00518.77
8.0.290.0060.00317.28
8.0.280.0070.00018.50
8.0.270.0000.00717.29
8.0.260.0040.00416.92
8.0.250.0040.00717.02
8.0.240.0040.00417.14
8.0.230.0070.00017.06
8.0.220.0030.00316.98
8.0.210.0000.00716.88
8.0.200.0040.00417.04
8.0.190.0000.00817.08
8.0.180.0000.00717.04
8.0.170.0040.00416.93
8.0.160.0000.00716.90
8.0.150.0070.00016.94
8.0.140.0000.00816.95
8.0.130.0000.00813.43
8.0.120.0050.00216.95
8.0.110.0000.00717.02
8.0.100.0040.00417.04
8.0.90.0000.00716.87
8.0.80.0080.01117.04
8.0.70.0000.00716.88
8.0.60.0030.00416.88
8.0.50.0070.00016.94
8.0.30.0100.00917.11
8.0.20.0110.00717.40
8.0.10.0050.00317.18
8.0.00.0130.00816.74
7.4.330.0060.00015.00
7.4.320.0030.00316.63
7.4.300.0060.00016.56
7.4.290.0030.00316.62
7.4.280.0040.00416.68
7.4.270.0080.00016.64
7.4.260.0030.00316.62
7.4.250.0040.00416.52
7.4.240.0020.00616.54
7.4.230.0020.00516.65
7.4.220.0110.00916.44
7.4.210.0110.00716.62
7.4.200.0030.00316.30
7.4.190.0000.00716.53
7.4.160.0060.01716.76
7.4.150.0070.01017.40
7.4.140.0040.01317.86
7.4.130.0120.00616.53
7.4.120.0080.01116.53
7.4.110.0100.00716.68
7.4.100.0140.00316.50
7.4.90.0140.00916.72
7.4.80.0090.01219.39
7.4.70.0120.00416.55
7.4.60.0060.00916.40
7.4.50.0000.00816.33
7.4.40.0030.01022.77
7.4.30.0100.00716.77
7.4.00.0030.01015.28
7.3.330.0000.00513.41
7.3.320.0000.00613.46
7.3.310.0030.00316.45
7.3.300.0000.00716.36
7.3.290.0120.00316.45
7.3.280.0080.01116.43
7.3.270.0060.01917.40
7.3.260.0110.00616.61
7.3.250.0080.01316.48
7.3.240.0100.00616.43
7.3.230.0090.00816.39
7.3.210.0090.00916.71
7.3.200.0140.00719.39
7.3.190.0180.00416.67
7.3.180.0040.01116.33
7.3.170.0090.00616.43
7.3.160.0080.00816.41
7.3.120.0030.01014.77
7.3.10.0080.00716.66
7.3.00.0070.01016.52
7.2.330.0120.01216.64
7.2.320.0140.01116.90
7.2.310.0060.00916.53
7.2.300.0100.00716.87
7.2.290.0130.00416.46
7.2.130.0110.00616.83
7.2.120.0060.00716.68
7.2.110.0060.00916.80
7.2.100.0110.00717.02
7.2.90.0020.01516.93
7.2.80.0060.01116.71
7.2.70.0100.00616.57
7.2.60.0100.00816.74
7.2.50.0050.01016.82
7.2.40.0140.00316.74
7.2.30.0110.00816.89
7.2.20.0080.01416.78
7.2.10.0090.00816.86
7.2.00.0060.00916.96
7.1.250.0110.00615.69
7.1.200.0100.00315.66
7.1.100.0030.01217.95
7.1.70.0120.01217.10
7.1.60.0070.01019.82
7.1.50.0070.00717.07
7.1.00.0000.08022.37
7.0.200.0000.00816.46
7.0.140.0030.07322.04
7.0.60.0100.07019.97
7.0.50.0170.04717.99
7.0.40.0030.09320.30
7.0.30.0500.07720.06
7.0.20.0170.04320.07
7.0.10.0030.04720.23
7.0.00.0100.08020.29
5.6.280.0030.07320.88
5.6.210.0070.04020.45
5.6.200.0170.05318.13
5.6.190.0130.05020.52
5.6.180.0370.05020.39
5.6.170.0430.07720.47
5.6.160.0070.08720.50
5.6.150.0000.06318.18
5.6.140.0100.08018.21
5.6.130.0000.08718.21
5.6.120.0130.07721.16
5.6.110.0170.07321.02
5.6.100.0070.07721.00
5.6.90.0130.06720.94
5.6.80.0070.07320.40
5.6.70.3500.02720.39
5.5.350.0070.07320.44
5.5.340.0030.07717.94
5.5.330.0000.05720.47
5.5.320.0300.07320.34
5.5.310.0200.03720.27
5.5.300.0070.08318.08
5.5.290.0100.05318.04
5.5.280.0030.04020.89
5.5.270.0130.04020.88
5.5.260.0000.06720.75
5.5.250.0030.07720.73
5.5.240.0130.06320.20
5.4.450.0770.05019.57
5.4.440.0100.05719.12
5.4.430.0030.06019.32
5.4.420.0130.05019.51
5.4.410.0130.05019.40
5.4.400.0800.00018.86
5.4.390.1000.00018.59
5.4.380.0270.05718.71
5.4.370.0270.05018.65
5.4.360.0170.05318.60
5.4.350.0200.05718.52
5.4.340.0370.07318.74
5.4.320.0070.03912.52
5.4.310.0060.04012.52
5.4.300.0050.03812.52
5.4.290.0070.04212.51
5.4.280.0090.03812.41
5.4.270.0070.05718.95
5.4.260.0130.04719.01
5.4.250.0170.05318.95
5.4.240.0070.05719.01
5.4.230.0130.06318.75
5.4.220.0130.05018.94
5.4.210.0170.05318.75
5.4.200.0100.05718.84
5.4.190.0130.07718.74
5.4.180.0070.05318.71
5.4.170.0030.05719.06
5.4.160.0070.07718.79
5.4.150.0230.06318.95
5.4.140.0170.06316.67
5.4.130.0230.05716.60
5.4.120.0070.05016.63
5.4.110.0170.04316.58
5.4.100.0100.06716.71
5.4.90.0130.06016.47
5.4.80.0100.06316.51
5.4.70.0100.04716.40
5.4.60.0070.05016.45
5.4.50.0100.04316.33
5.4.40.0070.05716.59
5.4.30.0170.04716.53
5.4.20.0200.04716.46
5.4.10.0170.06716.34
5.4.00.0300.05015.77
5.3.290.0080.04012.80
5.3.280.0100.05714.60
5.3.270.0230.06314.70
5.3.260.0200.06714.76
5.3.250.0100.06714.64
5.3.240.0100.05314.71
5.3.230.0170.04314.70
5.3.220.0130.04714.60
5.3.210.0070.06014.77
5.3.200.0200.06314.65
5.3.190.0130.04714.70
5.3.180.0170.04014.49
5.3.170.0230.06314.67
5.3.160.0100.06314.75
5.3.150.0200.05014.69
5.3.140.0030.05314.65
5.3.130.0070.06314.65
5.3.120.0100.07014.40
5.3.110.0070.05314.40
5.3.100.0100.05714.28
5.3.90.0100.04714.13
5.3.80.0030.05714.20
5.3.70.0070.05314.26
5.3.60.0100.04714.00
5.3.50.0070.06013.88
5.3.40.0170.05314.04
5.3.30.0100.06314.02
5.3.20.0170.04713.69
5.3.10.0100.04313.84
5.3.00.0170.05313.64
5.2.170.0000.06011.22
5.2.160.0070.04711.11
5.2.150.0100.04711.24
5.2.140.0130.03311.10
5.2.130.0070.04711.18
5.2.120.0130.05011.07
5.2.110.0100.05011.11
5.2.100.0070.04711.28
5.2.90.0070.06311.29
5.2.80.0030.04711.00
5.2.70.0100.06011.19
5.2.60.0070.04311.28
5.2.50.0130.03311.12
5.2.40.0100.03711.07
5.2.30.0070.05011.20
5.2.20.0030.05011.04
5.2.10.0130.04010.78
5.2.00.0100.04010.80
5.1.60.0070.0339.98
5.1.50.0170.0409.98
5.1.40.0030.03710.09
5.1.30.0070.04010.43
5.1.20.0030.04710.52
5.1.10.0070.03310.00
5.1.00.0030.04310.08
5.0.50.0000.0338.60
5.0.40.0070.0308.42
5.0.30.0100.0408.46
5.0.20.0130.0308.27
5.0.10.0030.0278.17
5.0.00.0030.0538.15
4.4.90.0030.0306.58
4.4.80.0000.0276.58
4.4.70.0030.0206.58
4.4.60.0000.0276.58
4.4.50.0070.0206.58
4.4.40.0030.0336.00
4.4.30.0000.0235.98
4.4.20.0000.0275.86
4.4.10.0000.0235.96
4.4.00.0070.0375.84
4.3.110.0070.0275.80
4.3.100.0130.0205.74
4.3.90.0030.0275.73
4.3.80.0030.0375.77
4.3.70.0070.0175.76
4.3.60.0100.0275.82
4.3.50.0030.0205.78
4.3.40.0000.0405.83
4.3.30.0000.0235.43
4.3.20.0100.0205.41
4.3.10.0000.0235.36
4.3.00.0230.0136.41

preferences:
44.84 ms | 401 KiB | 5 Q