3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 1: Read and write to 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 4. No redefining $test 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 $this->testy = $key; $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here class Intercept { public function getKey($test) { $array = (array) $test; reset($array); $first_key = key($array); print_r($array[$first_key]); //$v = array(); //$v[$first_key] = 'blah'; //$blah = $v[$first_key]; $blah= array(); $blah[0] = 'dobee'; $test->__set($array[$first_key] , $blah ); /* foreach($array as $k => $v) { print_r($k); print_r($v); } */ } } $intercept = new Intercept; $intercept->getKey($test); // 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.0150.00316.88
8.3.50.0090.01022.02
8.3.40.0120.00618.84
8.3.30.0110.00419.20
8.3.20.0110.00420.43
8.3.10.0040.00423.30
8.3.00.0090.00019.34
8.2.180.0100.01018.41
8.2.170.0000.01622.96
8.2.160.0070.01020.22
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0090.00026.16
8.2.120.0070.00022.25
8.2.110.0060.00322.25
8.2.100.0120.00017.78
8.2.90.0000.00819.27
8.2.80.0000.00817.97
8.2.70.0040.00417.61
8.2.60.0060.00617.80
8.2.50.0060.00318.07
8.2.40.0080.00019.88
8.2.30.0000.00717.89
8.2.20.0000.00717.77
8.2.10.0040.00419.91
8.2.00.0030.00617.82
8.1.280.0100.00325.92
8.1.270.0040.00423.92
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0060.00323.99
8.1.230.0050.00519.16
8.1.220.0000.00817.74
8.1.210.0060.00318.77
8.1.200.0090.00017.23
8.1.190.0080.00017.29
8.1.180.0030.00718.10
8.1.170.0040.00718.52
8.1.160.0040.00422.02
8.1.150.0020.00518.55
8.1.140.0050.00217.28
8.1.130.0000.00717.84
8.1.120.0000.00717.40
8.1.110.0040.00417.34
8.1.100.0050.00217.47
8.1.90.0040.00317.38
8.1.80.0070.00017.31
8.1.70.0000.00717.44
8.1.60.0000.00917.50
8.1.50.0030.00617.51
8.1.40.0040.00417.49
8.1.30.0060.00317.62
8.1.20.0000.00717.67
8.1.10.0040.00417.61
8.1.00.0000.00717.42
8.0.300.0060.00318.77
8.0.290.0000.00817.16
8.0.280.0070.00018.29
8.0.270.0030.00317.09
8.0.260.0030.00317.28
8.0.250.0040.00417.02
8.0.240.0000.00717.01
8.0.230.0030.00316.96
8.0.220.0000.00716.80
8.0.210.0030.00516.93
8.0.200.0000.00816.95
8.0.190.0040.00416.86
8.0.180.0060.00616.82
8.0.170.0040.00416.82
8.0.160.0070.00016.85
8.0.150.0000.00716.76
8.0.140.0070.00016.85
8.0.130.0030.00313.36
8.0.120.0000.00816.85
8.0.110.0070.00016.89
8.0.100.0040.00416.95
8.0.90.0040.00416.97
8.0.80.0090.00916.97
8.0.70.0050.00216.88
8.0.60.0040.00516.97
8.0.50.0030.00616.88
8.0.30.0110.00816.96
8.0.20.0100.01017.40
8.0.10.0000.00717.09
8.0.00.0070.01116.71
7.4.330.0000.00515.00
7.4.320.0000.00816.43
7.4.300.0030.00316.52
7.4.290.0030.00316.59
7.4.280.0070.00016.52
7.4.270.0040.00416.48
7.4.260.0030.00616.41
7.4.250.0040.00416.50
7.4.240.0020.00516.52
7.4.230.0030.00516.41
7.4.220.0140.00316.56
7.4.210.0080.00716.59
7.4.200.0070.00016.46
7.4.190.0040.00416.72
7.4.160.0090.01316.34
7.4.150.0180.00317.40
7.4.140.0050.01217.86
7.4.130.0140.00716.54
7.4.120.0090.00816.46
7.4.110.0100.01016.61
7.4.100.0120.00616.45
7.4.90.0120.00616.50
7.4.80.0090.01319.39
7.4.70.0060.01316.61
7.4.60.0070.01016.60
7.4.50.0060.00316.33
7.4.40.0030.01322.77
7.4.30.0030.01316.43
7.4.00.0070.00715.18
7.3.330.0000.00613.39
7.3.320.0030.00313.43
7.3.310.0030.00516.48
7.3.300.0040.00416.37
7.3.290.0040.01116.45
7.3.280.0090.01116.41
7.3.270.0060.01217.40
7.3.260.0070.01116.36
7.3.250.0100.00716.39
7.3.240.0160.00616.59
7.3.230.0130.00316.39
7.3.210.0090.00816.67
7.3.200.0090.00919.39
7.3.190.0110.01116.46
7.3.180.0130.00316.51
7.3.170.0060.01116.43
7.3.160.0070.01016.60
7.3.120.0140.00314.52
7.2.330.0080.00816.66
7.2.320.0060.01516.86
7.2.310.0090.00916.52
7.2.300.0100.00716.89
7.2.290.0090.01216.90
7.2.60.0000.01417.13
7.1.200.0030.01015.70
7.1.100.0030.01418.18
7.1.70.0000.01017.14
7.1.60.0060.00619.46
7.1.50.0100.01016.91
7.1.00.0030.07722.37
7.0.200.0000.01116.71
7.0.140.0030.07022.00
7.0.60.0030.04720.05
7.0.50.0030.08017.91
7.0.40.0070.09020.15
7.0.30.0270.07320.06
7.0.20.0230.05720.20
7.0.10.0200.08320.15
7.0.00.0030.06320.24
5.6.210.0170.07320.50
5.6.200.0100.07318.29
5.6.190.0130.03720.47
5.6.180.0200.04720.34
5.6.170.0170.04020.39
5.6.160.0070.08320.52
5.6.150.0070.07018.28
5.6.140.0070.07018.25
5.6.130.0100.08018.27
5.6.120.0100.04721.05
5.6.110.0030.07721.14
5.6.100.0000.04721.09
5.6.90.0130.07020.97
5.6.80.0070.06320.36
5.6.70.0370.03320.38
5.5.350.0130.07720.40
5.5.340.0070.03717.97
5.5.330.0030.07020.36
5.5.320.0270.06020.38
5.5.310.0130.04020.21
5.5.300.0100.04017.96
5.5.290.0070.08017.98
5.5.280.0130.08020.74
5.5.270.0070.06320.98
5.5.260.0100.08020.96
5.5.250.0130.07320.70
5.5.240.0030.03720.24
5.4.450.0670.07019.67
5.4.440.0930.05719.17
5.4.430.0270.06319.66
5.4.420.0630.05719.62
5.4.410.0800.07019.22
5.4.400.0600.05718.97
5.4.390.0770.05019.34
5.4.380.0400.06018.73
5.4.370.0300.05718.47
5.4.360.0300.05718.57
5.4.350.0330.04718.79
5.4.340.0270.06318.79
5.4.320.0070.03512.51
5.4.310.0030.04412.50
5.4.300.0100.03312.51
5.4.290.0090.05712.49
5.4.280.0060.06412.39
5.4.270.0070.05512.38
5.4.260.0120.06212.39
5.4.250.0110.06612.39
5.4.240.0140.07412.39
5.4.230.0090.05312.38
5.4.220.0070.04312.38
5.4.210.0110.04612.38
5.4.200.0080.04712.38
5.4.190.0070.05712.37
5.4.180.0070.05412.38
5.4.170.0090.05712.39
5.4.160.0100.05012.38
5.4.150.0110.05612.38
5.4.140.0060.04112.06
5.4.130.0060.03812.05
5.4.120.0060.04012.00
5.4.110.0100.03612.00
5.4.100.0050.04112.00
5.4.90.0090.04612.00
5.4.80.0120.04712.00
5.4.70.0070.05212.00
5.4.60.0170.05111.99
5.4.50.0120.04812.00
5.4.40.0120.05011.99
5.4.30.0060.05811.98
5.4.20.0100.04911.98
5.4.10.0080.05711.98
5.4.00.0070.05111.47
5.3.290.0100.04012.80
5.3.280.0050.04812.71
5.3.270.0060.04112.72
5.3.260.0040.04412.72
5.3.250.0140.03912.71
5.3.240.0140.04412.72
5.3.230.0070.05012.71
5.3.220.0090.05412.68
5.3.210.0130.07412.68
5.3.200.0080.06412.68
5.3.190.0100.05712.68
5.3.180.0090.06812.67
5.3.170.0090.05212.67
5.3.160.0070.05812.67
5.3.150.0140.04512.68
5.3.140.0120.04712.66
5.3.130.0040.04512.66
5.3.120.0060.04312.66
5.3.110.0110.03912.65
5.3.100.0090.03912.13
5.3.90.0100.03912.11
5.3.80.0090.05212.11
5.3.70.0080.04312.11
5.3.60.0160.07112.09
5.3.50.0210.07512.05
5.3.40.0180.07612.04
5.3.30.0180.07911.99
5.3.20.0140.07111.78
5.3.10.0060.07511.74
5.3.00.0060.06411.73
5.2.170.0070.0339.23
5.2.160.0070.0369.23
5.2.150.0060.0389.24
5.2.140.0080.0399.23
5.2.130.0050.0329.20
5.2.120.0080.0419.19
5.2.110.0040.0439.20
5.2.100.0080.0409.19
5.2.90.0070.0419.19
5.2.80.0050.0369.19
5.2.70.0080.0319.19
5.2.60.0080.0409.14
5.2.50.0070.0449.11
5.2.40.0070.0319.09
5.2.30.0050.0369.06
5.2.20.0070.0299.05
5.2.10.0070.0388.96
5.2.00.0090.0308.82
5.1.60.0050.0268.11
5.1.50.0060.0278.10
5.1.40.0060.0268.08
5.1.30.0060.0248.43
5.1.20.0090.0408.45
5.1.10.0040.0288.18
5.1.00.0080.0348.18
5.0.50.0100.0296.66
5.0.40.0060.0266.52
5.0.30.0050.0396.33
5.0.20.0080.0236.30
5.0.10.0070.0276.27
5.0.00.0060.0366.27
4.4.90.0060.0194.77
4.4.80.0070.0234.76
4.4.70.0040.0284.75
4.4.60.0040.0274.75
4.4.50.0040.0264.77
4.4.40.0130.0494.71
4.4.30.0110.0504.76
4.4.20.0050.0414.84
4.4.10.0090.0294.85
4.4.00.0100.0624.75
4.3.110.0060.0444.67
4.3.100.0080.0254.66
4.3.90.0070.0124.64
4.3.80.0010.0294.58
4.3.70.0020.0164.63
4.3.60.0040.0144.63
4.3.50.0040.0154.63
4.3.40.0020.0264.54
4.3.30.0020.0163.30
4.3.20.0020.0183.28
4.3.10.0050.0133.23
4.3.00.0030.01310.54

preferences:
49.76 ms | 401 KiB | 5 Q