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; 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.40.0110.00719.02
8.3.30.0120.00318.49
8.3.20.0040.00418.90
8.3.10.0090.00020.52
8.3.00.0050.00319.38
8.2.170.0060.01222.96
8.2.160.0070.00720.86
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0040.00420.89
8.2.110.0090.00019.45
8.2.100.0080.00817.60
8.2.90.0040.00418.22
8.2.80.0050.00219.36
8.2.70.0050.00317.75
8.2.60.0040.00417.93
8.2.50.0030.00518.07
8.2.40.0040.00419.95
8.2.30.0000.00718.05
8.2.20.0040.00417.79
8.2.10.0030.00517.55
8.2.00.0000.00717.70
8.1.270.0040.00424.66
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0030.00622.09
8.1.230.0000.01120.88
8.1.220.0000.00717.79
8.1.210.0030.00518.97
8.1.200.0060.00317.35
8.1.190.0030.00517.39
8.1.180.0050.00318.10
8.1.170.0040.00418.74
8.1.160.0000.00718.87
8.1.150.0040.00418.59
8.1.140.0070.00017.34
8.1.130.0030.00517.74
8.1.120.0040.00417.41
8.1.110.0020.00517.29
8.1.100.0040.00417.40
8.1.90.0030.00417.45
8.1.80.0000.00717.38
8.1.70.0030.00317.38
8.1.60.0040.00417.60
8.1.50.0000.00817.44
8.1.40.0080.00017.52
8.1.30.0040.00417.61
8.1.20.0080.00017.70
8.1.10.0000.00717.58
8.1.00.0000.00717.58
8.0.300.0050.00220.08
8.0.290.0040.00416.75
8.0.280.0000.00718.43
8.0.270.0080.00017.24
8.0.260.0030.00316.95
8.0.250.0030.00516.88
8.0.240.0000.00717.06
8.0.230.0030.00316.95
8.0.220.0030.00316.81
8.0.210.0000.00716.83
8.0.200.0030.00316.95
8.0.190.0070.00016.86
8.0.180.0040.00416.95
8.0.170.0030.00716.88
8.0.160.0040.00416.92
8.0.150.0040.00416.70
8.0.140.0040.00416.93
8.0.130.0030.00313.39
8.0.120.0040.00416.88
8.0.110.0000.00716.82
8.0.100.0040.00416.94
8.0.90.0030.00516.92
8.0.80.0060.01016.84
8.0.70.0040.00416.70
8.0.60.0000.00816.87
8.0.50.0070.00016.86
8.0.30.0130.00517.09
8.0.20.0070.01317.01
8.0.10.0000.00716.84
8.0.00.0100.01216.93
7.4.330.0020.00212.98
7.4.320.0030.00316.48
7.4.300.0000.00616.61
7.4.290.0030.00316.63
7.4.280.0060.00316.57
7.4.270.0080.00016.43
7.4.260.0030.00313.28
7.4.250.0040.00416.45
7.4.240.0030.00316.61
7.4.230.0070.00016.39
7.4.220.0050.01116.50
7.4.210.0060.01216.59
7.4.200.0070.00016.59
7.4.190.0070.00016.71
7.4.160.0150.00716.54
7.4.150.0030.01416.47
7.4.140.0160.01316.51
7.4.130.0070.01016.55
7.4.120.0060.01016.51
7.4.110.0130.00416.74
7.4.100.0140.00416.65
7.4.90.0090.00916.56
7.4.80.0160.00016.36
7.4.70.0000.01616.66
7.4.60.0070.00816.49
7.4.50.0120.00016.48
7.4.40.0100.00516.30
7.4.30.0180.00316.37
7.4.00.0030.00914.90
7.3.330.0060.00013.25
7.3.320.0000.00513.31
7.3.310.0070.00016.32
7.3.300.0030.00316.31
7.3.290.0040.01116.37
7.3.280.0030.01216.29
7.3.270.0070.01016.57
7.3.260.0180.00716.31
7.3.250.0100.00816.34
7.3.240.0090.01216.52
7.3.230.0090.00916.31
7.3.210.0100.00716.26
7.3.200.0080.01219.39
7.3.190.0070.01516.39
7.3.180.0070.01016.48
7.3.170.0070.01316.31
7.3.160.0090.00916.42
7.3.120.0000.01714.61
7.2.330.0030.01516.62
7.2.320.0110.01116.57
7.2.310.0180.00716.61
7.2.300.0040.01316.49
7.2.290.0150.00616.52
7.2.00.0070.00719.53
7.1.100.0040.00718.23
7.1.70.0030.00716.95
7.1.60.0110.01419.40
7.1.50.0030.02016.86
7.1.00.0000.07722.49
7.0.200.0570.00014.61
7.0.140.0030.07322.18
7.0.120.0070.07022.11
7.0.60.0100.04319.93
7.0.50.0070.08017.90
7.0.40.0100.06317.71
7.0.30.0100.08017.76
7.0.20.0030.05717.72
7.0.10.0000.05717.75
7.0.00.0070.05317.79
5.6.280.0030.07320.93
5.6.210.0030.04020.65
5.6.200.0100.03718.14
5.6.190.0130.07718.22
5.6.180.0130.07018.30
5.6.170.0030.06318.18
5.6.160.0070.08018.21
5.6.150.0070.07018.18
5.6.140.0000.05318.18
5.6.130.0070.08718.14
5.6.120.0100.04718.16
5.6.110.0030.07318.21
5.6.100.0030.08718.20
5.6.90.0070.04018.17
5.6.80.0100.07317.67
5.6.70.0030.04017.57
5.6.60.0030.06317.66
5.6.50.0100.04317.60
5.6.40.0030.05717.54
5.6.30.0030.04017.51
5.6.20.0000.04317.60
5.6.10.0030.04317.60
5.6.00.0030.04017.53
5.5.350.0200.04020.39
5.5.340.0000.04718.08
5.5.330.0030.07717.98
5.5.320.0030.05317.96
5.5.310.0070.08317.94
5.5.300.0030.05318.09
5.5.290.0070.06018.08
5.5.280.0030.05717.95
5.5.270.0230.06718.06
5.5.260.0100.08317.95
5.5.250.0070.08317.79
5.5.240.0100.04317.42
5.5.230.0030.08017.35
5.5.220.0070.07017.42
5.5.210.0030.07317.52
5.5.200.0030.06017.32
5.5.190.0000.04317.34
5.5.180.0070.04717.37
5.5.160.0070.03717.39
5.5.150.0030.04717.34
5.5.140.0070.08017.38
5.5.130.0070.07317.30
5.5.120.0170.06717.39
5.5.110.0100.07017.32
5.5.100.0030.07317.30
5.5.90.0100.07017.19
5.5.80.0000.04717.17
5.5.70.0100.07017.16
5.5.60.0030.08317.18
5.5.50.0070.05317.34
5.5.40.0100.07717.23
5.5.30.0070.05717.22
5.5.20.0100.07717.29
5.5.10.0130.06317.28
5.5.00.0070.03717.21
5.4.450.0130.07319.34
5.4.440.0030.07019.45
5.4.430.0070.05719.37
5.4.420.0070.07319.33
5.4.410.0030.08019.24
5.4.400.0130.07019.05
5.4.390.0070.05719.04
5.4.380.0030.07718.95
5.4.370.0130.06719.03
5.4.360.0030.08019.05
5.4.350.0030.05019.12
5.4.340.0000.04319.11
5.4.320.0070.03719.10
5.4.310.0030.04718.98
5.4.300.0100.07018.98
5.4.290.0000.06019.01
5.4.280.0030.04319.09
5.4.270.0100.07719.09
5.4.260.0100.06019.13
5.4.250.0100.04719.11
5.4.240.0070.04319.11
5.4.230.0030.04019.02
5.4.220.0070.04319.11
5.4.210.0070.07719.00
5.4.200.0100.04319.09
5.4.190.0000.04319.08
5.4.180.0270.05319.00
5.4.170.0070.03719.08
5.4.160.0100.04019.07
5.4.150.0070.07319.11
5.4.140.0030.07316.35
5.4.130.0130.06716.54
5.4.120.0030.03716.36
5.4.110.0000.05016.43
5.4.100.0070.04016.46
5.4.90.0070.06016.54
5.4.80.0070.07016.49
5.4.70.0070.05316.50
5.4.60.0130.05316.38
5.4.50.0000.04316.19
5.4.40.0130.06016.41
5.4.30.0130.07016.45
5.4.20.0130.07316.44
5.4.10.0070.07016.39
5.4.00.0100.06715.85
5.3.290.0070.07714.74
5.3.280.0170.06714.63
5.3.270.0200.02314.61
5.3.260.0000.08014.62
5.3.250.0200.06714.67
5.3.240.0070.06714.66
5.3.230.0070.04314.63
5.3.220.0000.04014.58
5.3.210.0030.05714.54
5.3.200.0030.04314.56
5.3.190.0070.06014.52
5.3.180.0070.06014.55
5.3.170.0070.07314.55
5.3.160.0070.06714.55
5.3.150.0030.04714.62
5.3.140.0100.07714.63
5.3.130.0000.08014.77
5.3.120.0030.06014.60
5.3.110.0070.07014.52
5.3.100.0070.07014.07
5.3.90.0100.07314.07
5.3.80.0030.08014.09
5.3.70.0070.07014.10
5.3.60.0130.07014.02
5.3.50.0070.05014.18
5.3.40.0030.06713.95
5.3.30.0100.04713.98
5.3.20.0000.04013.73
5.3.10.0030.03313.68
5.3.00.0030.03713.49
5.2.170.0030.04311.15
5.2.160.0030.06711.17
5.2.150.0100.03311.16
5.2.140.0030.03311.12
5.2.130.0000.03011.21
5.2.120.0000.03011.21
5.2.110.0000.03011.16
5.2.100.0000.03011.18
5.2.90.0000.03011.18
5.2.80.0000.03011.06
5.2.70.0030.02711.14
5.2.60.0000.03011.11
5.2.50.0030.02711.25
5.2.40.0000.03010.90
5.2.30.0030.02710.88
5.2.20.0030.02711.18
5.2.10.0000.03010.83
5.2.00.0000.03010.76
5.1.60.0030.02310.22
5.1.50.0030.03310.04
5.1.40.0030.0209.96
5.1.30.0100.02010.35
5.1.20.0000.02710.42
5.1.10.0000.02710.15
5.1.00.0030.02310.03
5.0.50.0030.0178.63
5.0.40.0030.0178.33
5.0.30.0000.0338.31
5.0.20.0000.0208.14
5.0.10.0000.0208.39
5.0.00.0000.0378.08
4.4.90.0000.0177.52
4.4.80.0000.0177.52
4.4.70.0030.0137.52
4.4.60.0070.0107.52
4.4.50.0030.0137.52
4.4.40.0030.0207.52
4.4.30.0000.0177.52
4.4.20.0000.0177.52
4.4.10.0000.0177.52
4.4.00.0000.0237.52
4.3.110.0030.0137.52
4.3.100.0000.0137.52
4.3.90.0000.0177.52
4.3.80.0000.0237.52
4.3.70.0000.0137.52
4.3.60.0030.0137.52
4.3.50.0070.0107.52
4.3.40.0030.0207.52
4.3.30.0000.0177.52
4.3.20.0000.0137.52
4.3.10.0000.0137.52
4.3.00.0000.0177.52

preferences:
41.47 ms | 400 KiB | 5 Q