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 class A implements ArrayAccess { private $callCount = 0; public $func; public function __construct(){ $this->func = function(){ $this->secret = "Foo"; }; } public function __invoke(){ return $this->func; } public function offsetSet($offset, $value) {} public function offsetExists($offset) { return true; } public function offsetUnset($offset) {} public function offsetGet($offset) { $this->callCount++; if ($this->callCount == 1){ $r = $this; } else { $r = "callback"; } return $r; } } $a = new A; $a->func = $a->func->bindTo($test, "Test"); $test->foo = $a; // 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.0140.00618.80
8.3.50.0090.01121.21
8.3.40.0110.00818.95
8.3.30.0070.00720.33
8.3.20.0090.00020.15
8.3.10.0080.00021.95
8.3.00.0000.00822.34
8.2.180.0190.00316.88
8.2.170.0090.00622.96
8.2.160.0030.01020.36
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0180.00026.16
8.2.120.0090.00019.68
8.2.110.0060.00322.26
8.2.100.0040.00819.26
8.2.90.0090.00019.25
8.2.80.0020.00519.34
8.2.70.0080.00017.63
8.2.60.0030.00517.91
8.2.50.0040.00418.07
8.2.40.0040.00418.22
8.2.30.0060.00318.22
8.2.20.0040.00417.76
8.2.10.0040.00417.84
8.2.00.0040.00417.85
8.1.280.0180.00325.92
8.1.270.0030.00524.66
8.1.260.0050.00326.35
8.1.250.0020.00528.09
8.1.240.0030.00723.90
8.1.230.0080.00319.10
8.1.220.0040.00417.77
8.1.210.0000.00818.77
8.1.200.0000.01117.35
8.1.190.0060.00317.43
8.1.180.0060.00320.11
8.1.170.0090.00018.59
8.1.160.0040.00422.17
8.1.150.0000.00818.66
8.1.140.0000.00817.48
8.1.130.0050.00317.78
8.1.120.0000.00717.41
8.1.110.0000.00717.40
8.1.100.0040.00417.57
8.1.90.0000.00717.43
8.1.80.0000.00817.38
8.1.70.0000.00717.46
8.1.60.0060.00317.55
8.1.50.0000.00817.57
8.1.40.0040.00417.57
8.1.30.0050.00317.66
8.1.20.0050.00317.60
8.1.10.0000.00717.61
8.1.00.0030.00517.42
8.0.300.0040.00418.77
8.0.290.0000.00717.05
8.0.280.0050.00318.46
8.0.270.0000.00717.29
8.0.260.0030.00316.79
8.0.250.0060.00016.98
8.0.240.0000.01116.98
8.0.230.0040.00417.01
8.0.220.0040.00416.81
8.0.210.0000.00716.95
8.0.200.0000.00616.99
8.0.190.0070.00017.02
8.0.180.0000.00816.86
8.0.170.0000.00816.99
8.0.160.0050.00316.88
8.0.150.0040.00416.73
8.0.140.0040.00416.88
8.0.130.0000.00513.32
8.0.120.0070.00316.88
8.0.110.0050.00316.91
8.0.100.0000.00716.97
8.0.90.0000.00716.83
8.0.80.0070.01016.93
8.0.70.0000.00916.82
8.0.60.0000.00716.88
8.0.50.0040.00416.72
8.0.30.0070.01217.19
8.0.20.0090.01017.40
8.0.10.0020.00517.00
8.0.00.0050.01416.99
7.4.330.0030.00315.00
7.4.320.0000.00616.39
7.4.300.0060.00016.61
7.4.290.0000.00816.63
7.4.280.0030.00316.61
7.4.270.0000.00716.68
7.4.260.0030.00316.52
7.4.250.0040.00416.61
7.4.240.0050.00216.54
7.4.230.0070.00016.61
7.4.220.0070.01016.54
7.4.210.0040.01116.56
7.4.200.0030.00316.41
7.4.190.0070.00016.63
7.4.160.0080.00816.77
7.4.150.0150.00417.40
7.4.140.0080.01017.86
7.4.130.0120.00816.50
7.4.120.0080.00816.57
7.4.110.0090.00916.57
7.4.100.0160.00716.67
7.4.90.0110.01216.38
7.4.80.0110.00419.39
7.4.70.0060.01216.58
7.4.60.0130.00316.55
7.4.50.0030.00316.41
7.4.40.0120.00622.77
7.4.30.0060.01116.51
7.4.00.0090.00614.98
7.3.330.0030.00313.43
7.3.320.0000.00513.32
7.3.310.0040.00416.38
7.3.300.0040.00416.30
7.3.290.0000.01416.41
7.3.280.0070.01116.41
7.3.270.0160.00917.40
7.3.260.0110.00616.42
7.3.250.0080.00916.38
7.3.240.0170.00016.70
7.3.230.0060.01216.39
7.3.210.0110.00516.53
7.3.200.0100.00719.39
7.3.190.0070.01516.49
7.3.180.0070.01416.57
7.3.170.0160.00016.47
7.3.160.0100.00716.58
7.3.120.0030.00714.95
7.2.330.0080.01116.80
7.2.320.0110.01116.66
7.2.310.0110.01416.45
7.2.300.0030.01416.48
7.2.290.0100.00716.89
7.2.00.0100.00319.41
7.1.100.0060.00618.25
7.1.70.0070.00717.38
7.1.60.0100.01419.21
7.1.50.0040.01916.94
7.1.00.0030.03322.51
7.0.200.0040.00916.80
7.0.140.0070.07322.02
7.0.60.0130.07019.95
7.0.50.0130.07317.89
7.0.40.0030.08320.18
7.0.30.0300.08020.38
7.0.20.0170.09020.06
7.0.10.0230.07020.09
7.0.00.0070.08320.18
5.6.280.0030.07320.79
5.6.210.0030.07720.68
5.6.200.0130.08018.19
5.6.190.0130.04720.38
5.6.180.0300.07020.39
5.6.170.0300.05020.71
5.6.160.0030.04720.54
5.6.150.0100.08018.16
5.6.140.0170.07318.18
5.6.130.0070.03718.15
5.6.120.0000.09721.14
5.6.110.0170.05020.98
5.6.100.0070.05021.12
5.6.90.0030.07320.86
5.6.80.0030.04020.30
5.6.70.0170.04020.38
5.5.350.0070.07020.54
5.5.340.0000.04017.93
5.5.330.0130.04320.40
5.5.320.0200.04320.27
5.5.310.0230.03720.19
5.5.300.0030.04018.00
5.5.290.0100.04317.97
5.5.280.0030.04020.67
5.5.270.0070.09320.90
5.5.260.0100.05720.90
5.5.250.0030.07320.72
5.5.240.0170.06320.09
5.4.450.0270.06019.31
5.4.440.0670.06019.61
5.4.430.0870.06319.16
5.4.420.0970.04019.63
5.4.410.0770.05719.21
5.4.400.0970.05318.68
5.4.390.1200.05018.52
5.4.380.0230.05318.74
5.4.370.0900.04318.46
5.4.360.0730.05318.52
5.4.350.0090.04112.03
5.4.340.0080.04712.03
5.4.320.0070.04112.52
5.4.310.0060.03812.52
5.4.300.0080.05112.52
5.4.290.0080.03712.51
5.4.280.0060.05012.41
5.4.270.0100.04712.41
5.4.260.0040.03912.41
5.4.250.0100.05318.94
5.4.240.0030.06718.96
5.4.230.0030.05719.08
5.4.220.0170.07718.88
5.4.210.0170.05019.00
5.4.200.0170.06718.76
5.4.190.0170.06718.74
5.4.180.0130.07318.83
5.4.170.0130.06718.95
5.4.160.0100.05318.82
5.4.150.0070.07718.68
5.4.140.0100.05016.57
5.4.130.0270.05716.60
5.4.120.0270.05316.64
5.4.110.0030.06016.41
5.4.100.0030.05716.48
5.4.90.0030.05316.44
5.4.80.0070.06316.52
5.4.70.0130.04316.43
5.4.60.0130.04316.36
5.4.50.0130.04016.62
5.4.40.0100.04716.50
5.4.30.0070.05016.67
5.4.20.0030.05316.44
5.4.10.0200.06716.61
5.4.00.0170.06015.81
5.3.290.0060.03812.80
5.3.280.0070.05314.75
5.3.270.0170.05314.63
5.3.260.0030.06014.76
5.3.250.0200.07314.61
5.3.240.0100.05314.76
5.3.230.0000.08014.79
5.3.220.0070.07314.65
5.3.210.0070.05314.60
5.3.200.0100.05014.58
5.3.190.0100.06314.57
5.3.180.0070.06314.55
5.3.170.0070.05314.67
5.3.160.0170.04714.66
5.3.150.0130.05314.71
5.3.140.0030.05714.71
5.3.130.0100.05014.56
5.3.120.0170.04314.57
5.3.110.0130.06014.56
5.3.100.0170.06714.23
5.3.90.0070.05314.22
5.3.80.0130.05014.21
5.3.70.0030.06314.25
5.3.60.0200.05713.99
5.3.50.0070.06014.04
5.3.40.0130.07713.87
5.3.30.0070.04714.11
5.3.20.0030.05313.80
5.3.10.0070.05013.64
5.3.00.0100.04713.83
5.2.170.0070.04711.05
5.2.160.0070.05711.33
5.2.150.0030.04311.32
5.2.140.0100.03310.98
5.2.130.0070.04011.20
5.2.120.0130.03011.08
5.2.110.0030.04311.27
5.2.100.0000.05310.95
5.2.90.0100.04011.08
5.2.80.0130.05011.18
5.2.70.0030.04311.05
5.2.60.0000.04311.13
5.2.50.0070.04311.11
5.2.40.0030.04711.18
5.2.30.0070.03711.06
5.2.20.0100.03311.13
5.2.10.0100.04710.94
5.2.00.0070.04310.80
5.1.60.0000.03710.22
5.1.50.0070.04310.05
5.1.40.0030.04710.06
5.1.30.0170.02310.57
5.1.20.0070.04010.45
5.1.10.0030.04010.09
5.1.00.0100.03310.30
5.0.50.0030.0378.63
5.0.40.0000.0308.38
5.0.30.0000.0438.22
5.0.20.0000.0308.30
5.0.10.0030.0278.29
5.0.00.0000.0438.24
4.4.90.0070.0177.41
4.4.80.0030.0207.41
4.4.70.0100.0207.41
4.4.60.0030.0207.41
4.4.50.0030.0237.42
4.4.40.0130.0277.41
4.4.30.0070.0237.42
4.4.20.0030.0207.42
4.4.10.0000.0237.42
4.4.00.0030.0337.42
4.3.110.0000.0237.42
4.3.100.0000.0237.42
4.3.90.0000.0237.42
4.3.80.0030.0337.42
4.3.70.0070.0207.42
4.3.60.0000.0277.42
4.3.50.0070.0177.42
4.3.40.0000.0377.42
4.3.30.0000.0237.42
4.3.20.0030.0207.42
4.3.10.0030.0207.42
4.3.00.0070.0236.09

preferences:
49.03 ms | 401 KiB | 5 Q