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(){ echo "A".$this->secret."B";die; }; } 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->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.0100.01018.43
8.3.50.0150.00321.08
8.3.40.0100.00718.88
8.3.30.0140.00020.35
8.3.20.0040.00420.21
8.3.10.0080.00021.96
8.3.00.0040.00422.40
8.2.180.0100.01016.75
8.2.170.0110.00722.96
8.2.160.0100.00320.23
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0040.00419.66
8.2.110.0030.00719.15
8.2.100.0030.00917.91
8.2.90.0090.00019.21
8.2.80.0080.00017.97
8.2.70.0040.00417.50
8.2.60.0060.00317.80
8.2.50.0000.00818.22
8.2.40.0080.00020.42
8.2.30.0030.00519.27
8.2.20.0040.00417.70
8.2.10.0040.00417.83
8.2.00.0040.00417.84
8.1.280.0000.01425.92
8.1.270.0050.00324.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00621.02
8.1.230.0080.00420.31
8.1.220.0050.00317.78
8.1.210.0050.00318.77
8.1.200.0030.00617.25
8.1.190.0040.00817.25
8.1.180.0040.00418.10
8.1.170.0000.00818.42
8.1.160.0000.00718.99
8.1.150.0000.00820.16
8.1.140.0000.00717.40
8.1.130.0030.00617.74
8.1.120.0000.00717.40
8.1.110.0030.00517.39
8.1.100.0080.00017.50
8.1.90.0000.00717.55
8.1.80.0040.00417.43
8.1.70.0040.00417.48
8.1.60.0040.00417.51
8.1.50.0040.00417.57
8.1.40.0050.00317.54
8.1.30.0050.00317.62
8.1.20.0040.00417.64
8.1.10.0030.00617.61
8.1.00.0000.00817.51
8.0.300.0000.00718.77
8.0.290.0060.00316.88
8.0.280.0030.00318.48
8.0.270.0070.00017.28
8.0.260.0070.00016.90
8.0.250.0080.00016.99
8.0.240.0110.00016.98
8.0.230.0000.00717.09
8.0.220.0000.00716.89
8.0.210.0000.00716.89
8.0.200.0000.00816.97
8.0.190.0000.00716.93
8.0.180.0000.00816.90
8.0.170.0070.00016.88
8.0.160.0030.00317.03
8.0.150.0040.00416.84
8.0.140.0000.00716.84
8.0.130.0030.00313.35
8.0.120.0000.00816.95
8.0.110.0050.00316.98
8.0.100.0070.00017.02
8.0.90.0000.00716.82
8.0.80.0120.00916.98
8.0.70.0040.00416.84
8.0.60.0000.00816.95
8.0.50.0030.00616.88
8.0.30.0130.00517.19
8.0.20.0090.01017.42
8.0.10.0040.00417.10
8.0.00.0110.00817.00
7.4.330.0050.00015.00
7.4.320.0000.00716.50
7.4.300.0030.00316.53
7.4.290.0040.00416.43
7.4.280.0040.00416.48
7.4.270.0000.00716.63
7.4.260.0030.00316.54
7.4.250.0020.00516.62
7.4.240.0020.00516.58
7.4.230.0060.00016.60
7.4.220.0150.00316.46
7.4.210.0090.00916.55
7.4.200.0070.00016.72
7.4.190.0000.00716.68
7.4.160.0070.01216.54
7.4.150.0060.01617.40
7.4.140.0160.00617.86
7.4.130.0020.01516.57
7.4.120.0110.00616.42
7.4.110.0060.01216.57
7.4.100.0100.00716.59
7.4.90.0060.01216.40
7.4.80.0120.00619.39
7.4.70.0070.01016.50
7.4.60.0080.00816.60
7.4.50.0030.00316.42
7.4.40.0100.00722.77
7.4.30.0040.01816.58
7.4.00.0100.00714.95
7.3.330.0000.00513.42
7.3.320.0060.00013.27
7.3.310.0070.00016.57
7.3.300.0070.00016.38
7.3.290.0060.00916.50
7.3.280.0090.00616.45
7.3.270.0140.00917.40
7.3.260.0140.00516.64
7.3.250.0110.01116.42
7.3.240.0120.00416.69
7.3.230.0110.00616.66
7.3.210.0030.01216.53
7.3.200.0070.01019.39
7.3.190.0030.02016.33
7.3.180.0100.00716.66
7.3.170.0110.01116.53
7.3.160.0130.00316.48
7.3.120.0070.01014.91
7.2.330.0100.00716.53
7.2.320.0120.00616.86
7.2.310.0160.00616.78
7.2.300.0150.00316.67
7.2.290.0090.00916.51
7.2.60.0000.01516.77
7.2.00.0040.01119.39
7.1.200.0090.00315.69
7.1.70.0000.00717.30
7.1.60.0150.00919.21
7.1.50.0070.01716.85
7.1.00.0030.03322.32
7.0.200.0030.00616.80
7.0.140.0000.07722.18
7.0.60.0070.04320.00
7.0.50.0130.07717.89
7.0.40.0130.08020.06
7.0.30.0370.07020.08
7.0.20.0300.07720.26
7.0.10.0230.06720.25
7.0.00.0100.08720.23
5.6.280.0100.06720.79
5.6.210.0070.06320.64
5.6.200.0200.06018.24
5.6.190.0070.08320.38
5.6.180.0300.06020.49
5.6.170.0430.07020.47
5.6.160.0130.04720.39
5.6.150.0030.08018.15
5.6.140.0070.05318.14
5.6.130.0030.04318.14
5.6.120.0100.07321.02
5.6.110.0070.04721.00
5.6.100.0130.07320.91
5.6.90.0170.05020.98
5.6.80.0000.04320.41
5.6.70.0230.07320.55
5.5.350.0100.07020.43
5.5.340.0070.03718.09
5.5.330.0100.04020.21
5.5.320.0300.06720.27
5.5.310.0170.04320.32
5.5.300.0030.04018.07
5.5.290.0030.08717.98
5.5.280.0000.04320.91
5.5.270.0170.05020.97
5.5.260.0070.08320.88
5.5.250.0030.07020.45
5.5.240.0130.06720.14
5.4.450.0370.07019.48
5.4.440.0870.05019.61
5.4.430.0830.05719.30
5.4.420.0570.06319.55
5.4.410.0170.05019.34
5.4.400.1470.05318.79
5.4.390.1200.05718.60
5.4.380.0200.05318.59
5.4.370.0330.03318.59
5.4.360.0130.05018.76
5.4.350.0140.05812.03
5.4.340.0090.03912.02
5.4.320.0030.03912.52
5.4.310.0030.04412.52
5.4.300.0050.04712.52
5.4.290.0160.04412.51
5.4.280.0100.04512.41
5.4.270.0050.03712.41
5.4.260.0070.03612.41
5.4.250.0100.06319.01
5.4.240.0030.06018.99
5.4.230.0000.08319.00
5.4.220.0070.06318.93
5.4.210.0170.06718.93
5.4.200.0030.06018.76
5.4.190.0170.04718.64
5.4.180.0130.06718.79
5.4.170.0170.04719.00
5.4.160.0100.06719.07
5.4.150.0270.05718.96
5.4.140.0070.07016.43
5.4.130.0070.05316.61
5.4.120.0030.08016.41
5.4.110.0070.05016.46
5.4.100.0100.04716.56
5.4.90.0170.04316.70
5.4.80.0130.04016.73
5.4.70.0100.05016.54
5.4.60.0030.07716.62
5.4.50.0200.06016.61
5.4.40.0030.05316.52
5.4.30.0070.07016.52
5.4.20.0200.04716.45
5.4.10.0070.06716.58
5.4.00.0070.05315.86
5.3.290.0060.04712.80
5.3.280.0070.06314.63
5.3.270.0030.06014.71
5.3.260.0070.08014.71
5.3.250.0070.05714.84
5.3.240.0130.05714.80
5.3.230.0070.06014.52
5.3.220.0070.05014.68
5.3.210.0070.05314.67
5.3.200.0000.05714.81
5.3.190.0000.05714.57
5.3.180.0100.05014.80
5.3.170.0130.04314.57
5.3.160.0070.04714.58
5.3.150.0030.05314.57
5.3.140.0100.04714.77
5.3.130.0100.04714.75
5.3.120.0130.06314.41
5.3.110.0070.05314.47
5.3.100.0100.04314.08
5.3.90.0130.05313.87
5.3.80.0100.07014.26
5.3.70.0070.05714.01
5.3.60.0270.04313.99
5.3.50.0130.06014.07
5.3.40.0070.05014.04
5.3.30.0100.05314.02
5.3.20.0170.04313.73
5.3.10.0100.05713.67
5.3.00.0100.07713.74
5.2.170.0030.04711.23
5.2.160.0030.04011.06
5.2.150.0000.06710.98
5.2.140.0030.04311.23
5.2.130.0030.04311.19
5.2.120.0030.04311.07
5.2.110.0170.04711.07
5.2.100.0070.04011.17
5.2.90.0070.04311.09
5.2.80.0070.04711.20
5.2.70.0070.04311.26
5.2.60.0000.06011.01
5.2.50.0100.04711.12
5.2.40.0070.04711.01
5.2.30.0030.04710.97
5.2.20.0030.04310.94
5.2.10.0030.05310.95
5.2.00.0130.03310.79
5.1.60.0030.05710.20
5.1.50.0030.0339.85
5.1.40.0070.03710.11
5.1.30.0130.03010.30
5.1.20.0030.03710.44
5.1.10.0030.04010.09
5.1.00.0130.03010.06
5.0.50.0070.0238.54
5.0.40.0030.0278.49
5.0.30.0000.0438.30
5.0.20.0070.02310.24
5.0.10.0000.03010.24
5.0.00.0030.04710.24
4.4.90.0030.0237.34
4.4.80.0000.0307.34
4.4.70.0030.0207.34
4.4.60.0000.0237.34
4.4.50.0000.0237.34
4.4.40.0030.0337.34
4.4.30.0030.0207.34
4.4.20.0000.0337.34
4.4.10.0000.0307.34
4.4.00.0030.0307.34
4.3.110.0000.0277.34
4.3.100.0100.01710.24
4.3.90.0100.01310.24
4.3.80.0070.03010.24
4.3.70.0030.02010.24
4.3.60.0000.03010.24
4.3.50.0000.03010.24
4.3.40.0030.03310.24
4.3.30.0100.02010.24
4.3.20.0030.02710.24
4.3.10.0030.02010.24
4.3.00.0070.0236.09

preferences:
51.11 ms | 401 KiB | 5 Q