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 function __invoke(){ $host = $this; return function() use ($host){ $this->secret = "HELLO WORLD"; }; } 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 = "FOO"; } return $r; } } $test->foo = new 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.0120.00918.55
8.3.50.0110.00721.14
8.3.40.0110.00418.84
8.3.30.0110.00320.34
8.3.20.0040.00420.34
8.3.10.0040.00421.66
8.3.00.0050.00222.52
8.2.180.0140.00716.63
8.2.170.0110.00422.96
8.2.160.0040.01120.47
8.2.150.0000.00824.18
8.2.140.0000.00924.66
8.2.130.0000.00826.16
8.2.120.0040.00419.78
8.2.110.0090.00022.25
8.2.100.0060.00619.32
8.2.90.0000.00719.35
8.2.80.0080.00019.17
8.2.70.0040.00417.75
8.2.60.0030.00618.05
8.2.50.0040.00418.07
8.2.40.0000.00818.32
8.2.30.0040.00418.13
8.2.20.0040.00417.72
8.2.10.0040.00417.83
8.2.00.0000.00917.71
8.1.280.0100.00725.92
8.1.270.0040.00424.66
8.1.260.0050.00226.35
8.1.250.0040.00428.09
8.1.240.0030.00623.97
8.1.230.0050.00519.02
8.1.220.0000.00917.74
8.1.210.0040.00418.77
8.1.200.0030.00617.36
8.1.190.0000.00817.43
8.1.180.0000.00720.08
8.1.170.0040.00418.64
8.1.160.0040.00422.20
8.1.150.0040.00418.70
8.1.140.0000.00817.38
8.1.130.0000.01117.86
8.1.120.0070.00017.39
8.1.110.0040.00417.57
8.1.100.0050.00217.43
8.1.90.0050.00217.39
8.1.80.0030.00517.45
8.1.70.0000.00717.47
8.1.60.0060.00317.59
8.1.50.0020.00517.51
8.1.40.0080.00017.43
8.1.30.0040.00417.60
8.1.20.0030.00517.64
8.1.10.0070.00017.57
8.1.00.0030.00617.54
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0070.00018.38
8.0.270.0030.00317.28
8.0.260.0000.00616.87
8.0.250.0000.00717.05
8.0.240.0030.00817.06
8.0.230.0070.00016.95
8.0.220.0030.00316.96
8.0.210.0070.00016.93
8.0.200.0030.00516.96
8.0.190.0040.00417.01
8.0.180.0030.00717.06
8.0.170.0030.00317.05
8.0.160.0050.00217.05
8.0.150.0080.00016.94
8.0.140.0040.00416.94
8.0.130.0070.00013.45
8.0.120.0000.00716.96
8.0.110.0040.00416.90
8.0.100.0070.00016.76
8.0.90.0000.00716.87
8.0.80.0040.01116.88
8.0.70.0040.00416.88
8.0.60.0040.00416.88
8.0.50.0040.00417.02
8.0.30.0130.01017.08
8.0.20.0090.00917.40
8.0.10.0070.00017.16
8.0.00.0060.01416.87
7.4.330.0050.00015.00
7.4.320.0060.00016.63
7.4.300.0080.00016.48
7.4.290.0050.00316.58
7.4.280.0000.00816.61
7.4.270.0060.00016.43
7.4.260.0050.00316.60
7.4.250.0040.00416.49
7.4.240.0040.00416.55
7.4.230.0060.00016.71
7.4.220.0090.00616.56
7.4.210.0100.00716.55
7.4.200.0000.00716.72
7.4.190.0000.00716.49
7.4.160.0130.00916.54
7.4.150.0060.01317.40
7.4.140.0140.00817.86
7.4.130.0090.00916.66
7.4.120.0100.01016.56
7.4.110.0030.01316.59
7.4.100.0070.01116.58
7.4.90.0140.00316.46
7.4.80.0100.00719.39
7.4.70.0150.00316.54
7.4.60.0140.00616.66
7.4.50.0060.00316.45
7.4.40.0070.01122.77
7.4.30.0100.01016.67
7.4.00.0030.01214.88
7.3.330.0030.00313.45
7.3.320.0060.00013.26
7.3.310.0000.00716.32
7.3.300.0030.00316.50
7.3.290.0080.00816.35
7.3.280.0070.01016.47
7.3.270.0140.00617.40
7.3.260.0130.01016.50
7.3.250.0150.00716.52
7.3.240.0060.01316.45
7.3.230.0060.01216.45
7.3.210.0060.01316.47
7.3.200.0070.01019.39
7.3.190.0160.00616.70
7.3.180.0110.00516.39
7.3.170.0090.00916.58
7.3.160.0060.00916.40
7.3.120.0040.01115.14
7.3.10.0040.00816.47
7.3.00.0000.01416.84
7.2.330.0070.01016.75
7.2.320.0140.00316.63
7.2.310.0060.01316.88
7.2.300.0100.00716.82
7.2.290.0140.00416.79
7.2.130.0030.00616.90
7.2.120.0140.00616.93
7.2.110.0070.00716.91
7.2.100.0080.00416.91
7.2.90.0090.00617.02
7.2.80.0090.00916.92
7.2.70.0040.01216.93
7.2.60.0080.00716.92
7.2.50.0030.00817.07
7.2.40.0030.00717.06
7.2.30.0050.00317.16
7.2.20.0000.01216.95
7.2.10.0080.00316.64
7.2.00.0080.00517.03
7.1.250.0070.00715.77
7.1.200.0100.00315.96
7.1.70.0030.01317.09
7.1.60.0130.01019.21
7.1.50.0070.01117.00
7.1.00.0030.06322.48
7.0.200.0060.00616.84
7.0.140.0130.06322.21
7.0.60.0100.07319.95
7.0.50.0130.06717.94
7.0.40.0170.07020.13
7.0.30.0230.05020.09
7.0.20.0270.05020.06
7.0.10.0270.07320.23
7.0.00.0100.06020.25
5.6.280.0100.06720.80
5.6.210.0130.07320.74
5.6.200.0100.08018.24
5.6.190.0130.07020.40
5.6.180.0200.04020.33
5.6.170.0370.10020.40
5.6.160.0100.08320.54
5.6.150.0030.05318.15
5.6.140.0130.07018.18
5.6.130.0030.08018.24
5.6.120.0100.03320.91
5.6.110.0000.04721.14
5.6.100.0070.06321.10
5.6.90.0030.05721.02
5.6.80.0100.06020.52
5.6.70.0170.04720.38
5.5.350.0030.04020.41
5.5.340.0030.04018.02
5.5.330.0070.05320.21
5.5.320.0270.03320.29
5.5.310.0230.04020.35
5.5.300.0030.04018.03
5.5.290.0100.07718.08
5.5.280.0100.04320.89
5.5.270.0000.04320.81
5.5.260.0230.07720.86
5.5.250.0200.07720.81
5.5.240.0100.07320.38
5.4.450.0770.05719.48
5.4.440.0630.08019.58
5.4.430.0130.05319.58
5.4.420.0770.05719.55
5.4.410.1030.05319.50
5.4.400.0100.05318.77
5.4.390.0300.07718.76
5.4.380.0270.05318.80
5.4.370.0170.04718.62
5.4.360.0200.04318.71
5.4.350.0090.04412.04
5.4.340.0090.03912.03
5.4.320.0060.04112.52
5.4.310.0040.03912.52
5.4.300.0050.03712.52
5.4.290.0040.04012.51
5.4.280.0070.03812.41
5.4.270.0060.03512.41
5.4.260.0030.04012.41
5.4.250.0030.08018.98
5.4.240.0070.07318.88
5.4.230.0030.05319.02
5.4.220.0100.06318.94
5.4.210.0030.07018.78
5.4.200.0130.07019.03
5.4.190.0000.07318.63
5.4.180.0030.08018.69
5.4.170.0070.05318.99
5.4.160.0100.05018.91
5.4.150.0100.05018.74
5.4.140.0070.05016.56
5.4.130.0070.05716.55
5.4.120.0030.07316.43
5.4.110.0000.05716.42
5.4.100.0070.05316.47
5.4.90.0070.05316.45
5.4.80.0200.05016.36
5.4.70.0100.05016.46
5.4.60.0000.06716.47
5.4.50.0030.06716.37
5.4.40.0130.04316.52
5.4.30.0030.04716.36
5.4.20.0030.05316.37
5.4.10.0030.06716.39
5.4.00.0000.06715.98
5.3.290.0060.04012.80
5.3.280.0070.05314.60
5.3.270.0030.06014.70
5.3.260.0130.04714.72
5.3.250.0030.05714.69
5.3.240.0070.05314.70
5.3.230.0130.05714.69
5.3.220.0030.06714.58
5.3.210.0000.06714.41
5.3.200.0030.05314.66
5.3.190.0000.07014.57
5.3.180.0070.05014.66
5.3.170.0100.07014.44
5.3.160.0000.05714.45
5.3.150.0000.05014.65
5.3.140.0070.05314.55
5.3.130.0100.05014.39
5.3.120.0030.05714.42
5.3.110.0000.08014.64
5.3.100.0070.06014.12
5.3.90.0070.05014.11
5.3.80.0030.05014.05
5.3.70.0100.05014.02
5.3.60.0030.06014.09
5.3.50.0070.05714.04
5.3.40.0030.05013.95
5.3.30.0100.04014.09
5.3.20.0070.06013.78
5.3.10.0030.07313.79
5.3.00.0030.07713.63
5.2.170.0000.04711.28
5.2.160.0030.04011.14
5.2.150.0070.04011.24
5.2.140.0100.04311.32
5.2.130.0030.05311.09
5.2.120.0070.03711.28
5.2.110.0100.04011.07
5.2.100.0030.05311.18
5.2.90.0000.04011.05
5.2.80.0030.06011.16
5.2.70.0000.05010.95
5.2.60.0000.04311.14
5.2.50.0030.05711.10
5.2.40.0070.04011.08
5.2.30.0030.04310.99
5.2.20.0030.03710.82
5.2.10.0100.05010.69
5.2.00.0070.05310.80
5.1.60.0030.03310.24
5.1.50.0030.03310.24
5.1.40.0100.04010.24
5.1.30.0070.03710.24
5.1.20.0000.04010.38
5.1.10.0030.03310.24
5.1.00.0070.03010.24
5.0.50.0030.03710.24
5.0.40.0000.03010.24
5.0.30.0030.04010.24
5.0.20.0000.04010.24
5.0.10.0030.02710.24
5.0.00.0030.04010.24
4.4.90.0070.01710.24
4.4.80.0070.03010.24
4.4.70.0070.02710.24
4.4.60.0030.02710.24
4.4.50.0030.02310.24
4.4.40.0000.03310.24
4.4.30.0030.02010.24
4.4.20.0030.02010.24
4.4.10.0030.02710.24
4.4.00.0030.03010.24
4.3.110.0000.02310.24
4.3.100.0030.02010.24
4.3.90.0030.02710.24
4.3.80.0070.03010.24
4.3.70.0030.02710.24
4.3.60.0000.02310.24
4.3.50.0000.02710.24
4.3.40.0030.03010.24
4.3.30.0000.03010.24
4.3.20.0000.03010.24
4.3.10.0000.02310.24
4.3.00.0100.0235.91

preferences:
49.62 ms | 401 KiB | 5 Q