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(){ $that = $this; return function() use ($that){ echo "A".$this->secret."B";die; }; } 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; } } $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.70.0090.00918.43
8.3.60.0110.00718.53
8.3.50.0110.00821.33
8.3.40.0140.00318.84
8.3.30.0070.00720.29
8.3.20.0040.00420.20
8.3.10.0050.00322.13
8.3.00.0050.00322.58
8.2.180.0120.00916.50
8.2.170.0040.01522.96
8.2.160.0100.00320.52
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0140.00026.16
8.2.120.0040.00419.54
8.2.110.0090.00022.32
8.2.100.0070.00419.32
8.2.90.0000.00719.17
8.2.80.0000.00819.39
8.2.70.0050.00517.75
8.2.60.0040.00417.78
8.2.50.0000.00818.07
8.2.40.0050.00318.22
8.2.30.0000.00718.03
8.2.20.0040.00417.75
8.2.10.0030.00617.74
8.2.00.0050.00217.71
8.1.280.0100.01025.92
8.1.270.0040.00424.66
8.1.260.0030.00526.35
8.1.250.0050.00228.09
8.1.240.0090.00023.73
8.1.230.0110.00019.12
8.1.220.0000.00917.79
8.1.210.0000.00818.77
8.1.200.0000.00917.50
8.1.190.0060.00317.52
8.1.180.0070.00020.24
8.1.170.0000.00818.45
8.1.160.0050.00322.23
8.1.150.0070.00018.71
8.1.140.0070.00017.38
8.1.130.0070.00417.77
8.1.120.0040.00417.54
8.1.110.0000.00717.49
8.1.100.0040.00417.53
8.1.90.0000.00817.48
8.1.80.0040.00417.50
8.1.70.0000.00817.41
8.1.60.0050.00317.51
8.1.50.0040.00417.45
8.1.40.0030.00517.54
8.1.30.0000.00917.61
8.1.20.0060.00317.57
8.1.10.0050.00217.48
8.1.00.0030.00517.50
8.0.300.0040.00418.77
8.0.290.0050.00217.05
8.0.280.0000.00818.51
8.0.270.0030.00317.23
8.0.260.0030.00316.95
8.0.250.0070.00016.92
8.0.240.0000.00817.03
8.0.230.0000.00717.00
8.0.220.0070.00016.90
8.0.210.0030.00316.87
8.0.200.0070.00016.91
8.0.190.0050.00217.04
8.0.180.0030.00516.92
8.0.170.0070.00016.89
8.0.160.0000.00716.94
8.0.150.0000.00716.97
8.0.140.0000.00716.96
8.0.130.0000.00613.43
8.0.120.0000.00916.92
8.0.110.0000.00816.91
8.0.100.0070.00017.00
8.0.90.0070.00016.83
8.0.80.0090.00616.93
8.0.70.0040.00416.94
8.0.60.0040.00316.78
8.0.50.0070.00016.77
8.0.30.0130.00517.10
8.0.20.0120.00717.44
8.0.10.0040.00416.97
8.0.00.0060.01416.83
7.4.330.0050.00015.00
7.4.320.0000.00616.62
7.4.300.0040.00416.52
7.4.290.0030.00316.45
7.4.280.0070.00016.51
7.4.270.0030.00316.62
7.4.260.0040.00416.63
7.4.250.0040.00416.64
7.4.240.0010.00616.49
7.4.230.0070.00016.50
7.4.220.0120.00416.47
7.4.210.0060.01116.66
7.4.200.0000.00816.71
7.4.190.0040.00416.79
7.4.160.0080.00816.66
7.4.150.0190.00017.40
7.4.140.0150.00517.86
7.4.130.0100.00916.62
7.4.120.0080.01316.54
7.4.110.0110.00816.68
7.4.100.0070.01016.61
7.4.90.0100.00716.47
7.4.80.0120.01219.39
7.4.70.0070.01116.47
7.4.60.0070.01016.68
7.4.50.0020.00516.36
7.4.40.0090.00622.77
7.4.30.0200.00016.66
7.4.00.0060.01014.86
7.3.330.0000.00513.43
7.3.320.0000.00513.43
7.3.310.0070.00016.54
7.3.300.0070.00016.50
7.3.290.0000.01516.44
7.3.280.0060.01016.46
7.3.270.0080.01017.40
7.3.260.0170.00616.70
7.3.250.0090.01516.42
7.3.240.0100.00616.47
7.3.230.0130.00316.48
7.3.210.0080.00816.53
7.3.200.0120.00319.39
7.3.190.0090.01316.64
7.3.180.0090.00616.45
7.3.170.0120.00616.62
7.3.160.0100.00616.60
7.3.120.0110.00614.82
7.3.110.0110.00714.85
7.3.100.0000.01514.93
7.3.90.0100.00314.96
7.3.80.0060.01014.99
7.3.70.0060.00314.99
7.3.60.0030.00614.69
7.3.50.0040.00714.68
7.3.40.0040.00714.92
7.3.30.0030.00714.88
7.3.20.0030.01016.52
7.3.10.0030.00716.54
7.3.00.0030.01016.54
7.2.330.0100.00716.45
7.2.320.0070.01416.45
7.2.310.0100.01316.80
7.2.300.0070.01416.75
7.2.290.0130.00916.50
7.2.250.0160.00315.05
7.2.240.0100.00715.38
7.2.230.0100.00615.34
7.2.220.0060.00614.86
7.2.210.0040.01115.14
7.2.200.0050.00514.93
7.2.190.0060.00915.02
7.2.180.0120.00015.15
7.2.170.0090.00615.10
7.1.330.0040.01115.54
7.1.320.0040.00415.71
7.1.310.0000.01515.93
7.1.300.0000.00815.63
7.1.290.0040.00815.95
7.1.280.0090.00615.38
7.1.270.0070.00315.56
7.1.260.0040.00715.80
7.1.100.0030.00718.16
7.1.70.0040.00417.34
7.1.60.0060.01919.21
7.1.50.0040.00716.89
7.1.00.0030.04722.40
7.0.200.0000.00816.60
7.0.140.0070.07322.16
7.0.60.0100.05719.94
7.0.50.0030.05717.90
7.0.40.0030.08020.21
7.0.30.0270.04720.30
7.0.20.0330.07020.24
7.0.10.0300.06020.07
7.0.00.0100.03720.32
5.6.280.0100.07021.16
5.6.210.0030.08020.49
5.6.200.0030.08318.18
5.6.190.0130.04020.38
5.6.180.0330.07720.48
5.6.170.0200.05320.44
5.6.160.0130.08020.50
5.6.150.0000.08318.18
5.6.140.0130.05018.17
5.6.130.0130.06018.16
5.6.120.0070.05320.91
5.6.110.0070.08321.01
5.6.100.0170.07320.99
5.6.90.0170.07320.99
5.6.80.0000.04020.39
5.6.70.0300.07020.38
5.5.350.0000.09720.54
5.5.340.0170.07718.14
5.5.330.0100.03320.21
5.5.320.0300.07320.19
5.5.310.0130.04320.36
5.5.300.0000.04018.07
5.5.290.0100.05718.07
5.5.280.0100.04020.82
5.5.270.0130.08020.89
5.5.260.0130.06020.98
5.5.250.0100.05720.57
5.5.240.0100.05020.20
5.4.450.0130.05719.34
5.4.440.0670.05319.38
5.4.430.0900.03719.30
5.4.420.0170.04719.16
5.4.410.0800.05719.32
5.4.400.2600.06018.78
5.4.390.3930.06318.84
5.4.380.0170.05718.79
5.4.370.0770.04718.79
5.4.360.0730.05018.74
5.4.350.0020.05212.04
5.4.340.0070.04312.03
5.4.320.0070.03512.52
5.4.310.0060.03812.52
5.4.300.0050.03712.52
5.4.290.0060.03612.51
5.4.280.0080.04112.41
5.4.270.0040.03812.41
5.4.260.0050.03712.41
5.4.250.0170.06718.84
5.4.240.0070.08018.63
5.4.230.0130.05018.92
5.4.220.0070.05718.97
5.4.210.0100.05318.60
5.4.200.0100.05018.63
5.4.190.0200.04018.96
5.4.180.0070.06018.90
5.4.170.0070.05718.94
5.4.160.0070.05718.93
5.4.150.0100.08018.93
5.4.140.0100.07316.60
5.4.130.0130.04316.43
5.4.120.0030.05316.36
5.4.110.0170.06016.37
5.4.100.0070.05016.61
5.4.90.0200.05716.62
5.4.80.0030.06716.55
5.4.70.0100.04716.40
5.4.60.0200.06316.48
5.4.50.0070.05316.41
5.4.40.0070.05016.46
5.4.30.0100.05016.50
5.4.20.0130.05016.33
5.4.10.0100.05716.39
5.4.00.0100.06715.84
5.3.290.0060.03812.80
5.3.280.0200.06014.69
5.3.270.0070.06014.70
5.3.260.0030.05714.65
5.3.250.0130.04314.45
5.3.240.0030.06314.62
5.3.230.0100.05014.63
5.3.220.0100.05714.67
5.3.210.0100.05314.55
5.3.200.0030.05714.67
5.3.190.0100.05314.76
5.3.180.0170.04714.55
5.3.170.0130.06014.58
5.3.160.0030.05714.55
5.3.150.0030.05314.75
5.3.140.0070.05314.55
5.3.130.0100.07014.65
5.3.120.0070.05714.69
5.3.110.0130.06014.55
5.3.100.0000.05713.88
5.3.90.0000.05714.00
5.3.80.0030.05314.03
5.3.70.0130.06014.11
5.3.60.0000.07013.99
5.3.50.0070.06313.79
5.3.40.0100.04314.03
5.3.30.0070.04713.99
5.3.20.0070.04313.79
5.3.10.0130.03713.81
5.3.00.0200.04713.79
5.2.170.0070.04011.23
5.2.160.0070.04711.23
5.2.150.0070.04011.25
5.2.140.0100.05011.12
5.2.130.0030.05011.21
5.2.120.0070.04011.19
5.2.110.0100.03711.18
5.2.100.0070.03711.25
5.2.90.0130.04311.15
5.2.80.0030.04011.16
5.2.70.0070.05711.08
5.2.60.0100.04010.89
5.2.50.0030.04711.11
5.2.40.0030.05010.98
5.2.30.0100.05011.06
5.2.20.0100.03311.05
5.2.10.0000.05710.95
5.2.00.0030.03710.70
5.1.60.0030.03310.24
5.1.50.0000.03710.24
5.1.40.0030.03310.24
5.1.30.0030.03710.42
5.1.20.0070.03310.24
5.1.10.0000.03710.24
5.1.00.0030.03710.24
5.0.50.0030.02710.24
5.0.40.0030.02310.24
5.0.30.0000.04310.24
5.0.20.0030.02710.24
5.0.10.0000.03010.24
5.0.00.0030.04010.24
4.4.90.0030.02010.24
4.4.80.0000.03010.24
4.4.70.0030.02010.24
4.4.60.0000.02710.24
4.4.50.0000.02310.24
4.4.40.0030.03010.24
4.4.30.0000.02310.24
4.4.20.0000.03010.24
4.4.10.0030.02310.24
4.4.00.0030.03310.24
4.3.110.0000.02310.24
4.3.100.0000.02310.24
4.3.90.0000.02010.24
4.3.80.0070.02710.24
4.3.70.0070.01710.24
4.3.60.0030.02310.24
4.3.50.0000.02310.24
4.3.40.0070.02710.24
4.3.30.0030.02310.24
4.3.20.0000.02310.24
4.3.10.0000.02310.24
4.3.00.0000.0236.09

preferences:
47.87 ms | 401 KiB | 5 Q