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; } public function foo(Test $obj){ echo $obj->secret;die; } } $test = new Test; // start editing here class TestM extends Test { private $secret = "Foo"; public function foo(Test $obj){ echo $obj->secret;die; $obj->secret = "HELLO WORLD"; } } $testM = new TestM; $test->foo($testM); // 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.0110.00718.30
8.3.50.0160.00321.20
8.3.40.0090.00618.75
8.3.30.0100.00320.34
8.3.20.0040.00419.96
8.3.10.0060.00322.10
8.3.00.0050.00322.52
8.2.180.0060.01216.88
8.2.170.0070.00722.96
8.2.160.0070.00720.39
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0130.00626.16
8.2.120.0040.00419.89
8.2.110.0100.00021.00
8.2.100.0090.00317.84
8.2.90.0040.00419.09
8.2.80.0050.00317.97
8.2.70.0080.00017.63
8.2.60.0040.00417.93
8.2.50.0040.00418.07
8.2.40.0000.00718.03
8.2.30.0080.00017.98
8.2.20.0040.00417.82
8.2.10.0080.00017.57
8.2.00.0000.00717.74
8.1.280.0070.00725.92
8.1.270.0050.00324.66
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00621.27
8.1.230.0110.00017.45
8.1.220.0000.00817.74
8.1.210.0090.00018.77
8.1.200.0030.00917.35
8.1.190.0090.00017.23
8.1.180.0040.00418.76
8.1.170.0040.00418.55
8.1.160.0000.00722.15
8.1.150.0050.00218.52
8.1.140.0000.00717.26
8.1.130.0050.00317.88
8.1.120.0040.00417.41
8.1.110.0040.00417.30
8.1.100.0040.00417.45
8.1.90.0040.00417.43
8.1.80.0070.00017.35
8.1.70.0000.00817.30
8.1.60.0030.00617.48
8.1.50.0040.00417.43
8.1.40.0050.00317.54
8.1.30.0000.00817.63
8.1.20.0080.00017.70
8.1.10.0000.00817.62
8.1.00.0060.00617.32
8.0.300.0040.00418.77
8.0.290.0030.00516.75
8.0.280.0000.01018.46
8.0.270.0000.00817.30
8.0.260.0060.00016.85
8.0.250.0040.00417.07
8.0.240.0060.00316.93
8.0.230.0070.00016.93
8.0.220.0080.00017.00
8.0.210.0000.00716.91
8.0.200.0070.00016.96
8.0.190.0000.00716.89
8.0.180.0030.00616.94
8.0.170.0080.00016.92
8.0.160.0000.00716.84
8.0.150.0000.00716.75
8.0.140.0050.00316.77
8.0.130.0000.00613.29
8.0.120.0050.00316.69
8.0.110.0070.00016.72
8.0.100.0000.00716.92
8.0.90.0080.00016.87
8.0.80.0000.02016.78
8.0.70.0040.00416.88
8.0.60.0000.00716.86
8.0.50.0050.00216.74
8.0.30.0150.00416.94
8.0.20.0090.00917.40
8.0.10.0000.00716.95
8.0.00.0110.00816.70
7.4.330.0050.00015.00
7.4.320.0000.00616.47
7.4.300.0000.00616.65
7.4.290.0030.00416.53
7.4.280.0000.00716.50
7.4.270.0030.00516.59
7.4.260.0000.00716.50
7.4.250.0030.00316.59
7.4.240.0020.00516.53
7.4.230.0060.00016.39
7.4.220.0100.00716.52
7.4.210.0090.00516.63
7.4.200.0040.00416.49
7.4.190.0030.00316.68
7.4.160.0030.02016.50
7.4.150.0210.00417.40
7.4.140.0060.01217.86
7.4.130.0050.01416.51
7.4.120.0100.00816.51
7.4.110.0070.01016.46
7.4.100.0120.00616.36
7.4.90.0150.00416.54
7.4.80.0070.01019.39
7.4.70.0100.01316.55
7.4.60.0000.01716.52
7.4.50.0030.00516.24
7.4.40.0000.01522.77
7.4.30.0110.00616.52
7.4.00.0030.00714.79
7.3.330.0000.00613.34
7.3.320.0050.00013.17
7.3.310.0000.00816.38
7.3.300.0070.00016.32
7.3.290.0030.01016.31
7.3.280.0090.00816.31
7.3.270.0120.00617.40
7.3.260.0030.01516.23
7.3.250.0110.01216.33
7.3.240.0120.00616.29
7.3.230.0030.01416.52
7.3.210.0100.00716.46
7.3.200.0090.01219.39
7.3.190.0060.01116.23
7.3.180.0040.01116.26
7.3.170.0090.01416.39
7.3.160.0030.01416.35
7.3.120.0060.01014.91
7.2.330.0100.00716.66
7.2.320.0030.01416.55
7.2.310.0080.01416.39
7.2.300.0100.00616.71
7.2.290.0140.00416.75
7.2.00.0040.01219.40
7.1.100.0080.00317.97
7.1.70.0080.00317.33
7.1.60.0110.01419.21
7.1.50.0070.01517.04
7.1.00.0070.07322.30
7.0.200.0130.00614.74
7.0.140.0170.06322.09
7.0.60.0000.06720.03
7.0.50.0100.07717.82
7.0.40.0030.09020.23
7.0.30.0430.05320.33
7.0.20.0200.08720.26
7.0.10.0300.07720.17
7.0.00.0130.07720.32
5.6.280.0030.07320.99
5.6.210.0070.08020.55
5.6.200.0170.07018.16
5.6.190.0100.04020.61
5.6.180.0230.04020.33
5.6.170.0270.08720.51
5.6.160.0100.08020.54
5.6.150.0030.05718.23
5.6.140.0130.03318.21
5.6.130.0130.07318.27
5.6.120.0030.05721.13
5.6.110.0000.04721.01
5.6.100.0100.08320.96
5.6.90.0030.05020.95
5.6.80.0000.04320.37
5.6.70.0200.07320.38
5.5.350.0170.06320.40
5.5.340.0000.04017.99
5.5.330.0030.05020.13
5.5.320.0200.03720.31
5.5.310.0200.04320.27
5.5.300.0030.04017.98
5.5.290.0030.04718.06
5.5.280.0100.06320.70
5.5.270.0030.05020.88
5.5.260.0070.08320.88
5.5.250.0130.05020.79
5.5.240.0070.07020.16
5.4.450.0670.07319.20
5.4.440.0630.05019.16
5.4.430.0630.05719.61
5.4.420.0770.06719.45
5.4.410.0970.04719.48
5.4.400.0270.06318.89
5.4.390.0400.04718.75
5.4.380.0270.04718.50
5.4.370.0100.05718.78
5.4.360.0130.05318.79
5.4.350.0050.03912.02
5.4.340.0090.03812.02
5.4.320.0060.03612.50
5.4.310.0060.03712.50
5.4.300.0080.04812.50
5.4.290.0030.04112.50
5.4.280.0070.03412.39
5.4.270.0050.03912.39
5.4.260.0120.04912.39
5.4.250.0070.05718.93
5.4.240.0130.05019.09
5.4.230.0100.05018.79
5.4.220.0030.06018.62
5.4.210.0030.05718.99
5.4.200.0170.05018.99
5.4.190.0070.05718.93
5.4.180.0170.05318.99
5.4.170.0070.06019.02
5.4.160.0270.04018.95
5.4.150.0100.05318.79
5.4.140.0130.06316.45
5.4.130.0070.06016.40
5.4.120.0030.06316.63
5.4.110.0070.05716.47
5.4.100.0070.05316.61
5.4.90.0200.04016.53
5.4.80.0070.04716.53
5.4.70.0130.06716.61
5.4.60.0100.07016.39
5.4.50.0030.05716.39
5.4.40.0030.06316.68
5.4.30.0070.06716.54
5.4.20.0170.04716.30
5.4.10.0070.05316.46
5.4.00.0070.05015.86
5.3.290.0060.04212.80
5.3.280.0000.05714.67
5.3.270.0170.05014.54
5.3.260.0100.06314.70
5.3.250.0200.05714.70
5.3.240.0170.05714.64
5.3.230.0100.07014.52
5.3.220.0000.07314.71
5.3.210.0100.06314.59
5.3.200.0100.06714.60
5.3.190.0030.05714.64
5.3.180.0000.06014.41
5.3.170.0070.05014.56
5.3.160.0070.05314.75
5.3.150.0030.05714.59
5.3.140.0100.07014.57
5.3.130.0200.05714.69
5.3.120.0230.05314.64
5.3.110.0170.06714.58
5.3.100.0100.05014.21
5.3.90.0030.05313.86
5.3.80.0130.04714.19
5.3.70.0070.06014.11
5.3.60.0070.05014.01
5.3.50.0070.06713.95
5.3.40.0000.06313.95
5.3.30.0170.05713.96
5.3.20.0100.06713.79
5.3.10.0170.04313.61
5.3.00.0130.04713.55
5.2.170.0030.05311.22
5.2.160.0170.03711.18
5.2.150.0070.05011.33
5.2.140.0170.05311.13
5.2.130.0170.04311.29
5.2.120.0100.05711.08
5.2.110.0130.04011.18
5.2.100.0070.04011.01
5.2.90.0030.04311.08
5.2.80.0070.04011.09
5.2.70.0130.05011.28
5.2.60.0070.05711.14
5.2.50.0130.03311.02
5.2.40.0070.03711.08
5.2.30.0070.04310.97
5.2.20.0100.05010.95
5.2.10.0100.03311.03
5.2.00.0030.05310.69
5.1.60.0100.03010.24
5.1.50.0000.04310.24
5.1.40.0100.04010.24
5.1.30.0100.04710.34
5.1.20.0070.04710.36
5.1.10.0070.04310.24
5.1.00.0030.03710.24
5.0.50.0030.03010.24
5.0.40.0000.03310.24
5.0.30.0100.04010.24
5.0.20.0070.02710.24
5.0.10.0100.03310.24
5.0.00.0070.04710.24
4.4.90.0030.02310.24
4.4.80.0030.02710.24
4.4.70.0000.03310.24
4.4.60.0100.02010.24
4.4.50.0000.03710.24
4.4.40.0030.03310.24
4.4.30.0030.03010.24
4.4.20.0030.02010.24
4.4.10.0000.02710.24
4.4.00.0000.04010.24
4.3.110.0000.03310.24
4.3.100.0030.03010.24
4.3.90.0030.02310.24
4.3.80.0100.02710.24
4.3.70.0000.02310.24
4.3.60.0000.02310.24
4.3.50.0070.01710.24
4.3.40.0070.02710.24
4.3.30.0030.02010.24
4.3.20.0030.02710.24
4.3.10.0030.02710.24
4.3.00.0200.0135.87

preferences:
61.54 ms | 401 KiB | 5 Q