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; public $testy; final public function run() { call_user_func($this->callback); die('here'.$this->testy); 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(); $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.0040.01116.88
8.3.50.0200.00922.05
8.3.40.0100.00718.67
8.3.30.0140.00019.30
8.3.20.0080.00020.19
8.3.10.0080.00023.51
8.3.00.0050.00319.50
8.2.180.0210.00018.41
8.2.170.0120.00322.96
8.2.160.0100.00320.39
8.2.150.0060.00324.18
8.2.140.0040.01124.66
8.2.130.0100.00726.16
8.2.120.0000.00822.13
8.2.110.0060.00322.02
8.2.100.0070.00417.90
8.2.90.0000.00819.23
8.2.80.0040.00418.13
8.2.70.0040.00417.75
8.2.60.0090.00018.05
8.2.50.0060.00618.07
8.2.40.0060.00319.94
8.2.30.0040.00418.16
8.2.20.0000.00917.89
8.2.10.0040.00418.21
8.2.00.0000.01117.69
8.1.280.0040.01425.92
8.1.270.0040.00423.91
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00623.80
8.1.230.0160.00018.95
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0030.00617.38
8.1.190.0030.00517.53
8.1.180.0000.00919.01
8.1.170.0050.00318.59
8.1.160.0000.00822.03
8.1.150.0000.00918.65
8.1.140.0000.00717.39
8.1.130.0000.00717.84
8.1.120.0050.00317.51
8.1.110.0040.00417.50
8.1.100.0040.00417.38
8.1.90.0040.00417.40
8.1.80.0030.00317.49
8.1.70.0070.00017.44
8.1.60.0060.00317.59
8.1.50.0080.00017.50
8.1.40.0080.00017.55
8.1.30.0030.00617.55
8.1.20.0000.00817.59
8.1.10.0000.00817.63
8.1.00.0040.00417.52
8.0.300.0000.00718.77
8.0.290.0070.00017.16
8.0.280.0000.00818.38
8.0.270.0000.00717.24
8.0.260.0000.00717.38
8.0.250.0070.00016.91
8.0.240.0080.00016.95
8.0.230.0030.00316.97
8.0.220.0030.00316.95
8.0.210.0040.00416.96
8.0.200.0000.00617.01
8.0.190.0030.00517.02
8.0.180.0030.00616.93
8.0.170.0080.00016.90
8.0.160.0030.00417.00
8.0.150.0040.00416.89
8.0.140.0040.00416.92
8.0.130.0030.00513.41
8.0.120.0040.00416.86
8.0.110.0070.00016.96
8.0.100.0000.00716.94
8.0.90.0000.00716.95
8.0.80.0070.01016.86
8.0.70.0040.00416.89
8.0.60.0040.00416.96
8.0.50.0040.00416.89
8.0.30.0070.01517.09
8.0.20.0120.00917.40
8.0.10.0000.00916.98
8.0.00.0090.00916.79
7.4.330.0020.00215.00
7.4.320.0000.00616.65
7.4.300.0040.00416.44
7.4.290.0030.00316.64
7.4.280.0050.00316.53
7.4.270.0040.00416.52
7.4.260.0070.00016.47
7.4.250.0030.00616.35
7.4.240.0050.00316.53
7.4.230.0030.00316.38
7.4.220.0090.00916.48
7.4.210.0070.00816.65
7.4.200.0040.00416.69
7.4.190.0000.00716.62
7.4.160.0080.00816.68
7.4.150.0060.01217.40
7.4.140.0050.01317.86
7.4.130.0100.00716.48
7.4.120.0100.01016.56
7.4.110.0150.00816.40
7.4.100.0080.00816.68
7.4.90.0130.00816.66
7.4.80.0070.01119.39
7.4.70.0110.01116.59
7.4.60.0110.00616.45
7.4.50.0030.00516.64
7.4.40.0040.01222.77
7.4.30.0110.01016.67
7.4.00.0060.00915.02
7.3.330.0060.00013.25
7.3.320.0060.00013.29
7.3.310.0050.00216.24
7.3.300.0060.00316.48
7.3.290.0080.01216.36
7.3.280.0070.01316.40
7.3.270.0100.00717.40
7.3.260.0070.01016.70
7.3.250.0120.00616.40
7.3.240.0080.00816.41
7.3.230.0120.01216.48
7.3.210.0130.00316.50
7.3.200.0090.01419.39
7.3.190.0150.00816.53
7.3.180.0100.00716.39
7.3.170.0100.00716.48
7.3.160.0110.00516.40
7.3.120.0070.00414.88
7.2.330.0140.00316.50
7.2.320.0100.00716.76
7.2.310.0070.01316.70
7.2.300.0110.00616.43
7.2.290.0100.00716.54
7.2.60.0080.00317.03
7.2.00.0060.00619.22
7.1.200.0060.00615.77
7.1.100.0070.00318.11
7.1.70.0000.00717.09
7.1.60.0090.01619.46
7.1.50.0070.01717.11
7.1.00.0070.07322.26
7.0.200.0030.00616.78
7.0.140.0030.07022.07
7.0.110.0070.03719.96
7.0.100.0070.03719.89
7.0.90.0070.03719.96
7.0.80.0030.04019.91
7.0.70.0070.03319.90
7.0.60.0070.04719.91
7.0.50.0000.06020.50
7.0.40.0100.08320.05
7.0.30.0130.07320.04
7.0.20.0130.07020.12
7.0.10.0170.06320.14
7.0.00.0100.04320.05
5.6.280.0100.07020.79
5.6.260.0000.05020.51
5.6.250.0000.05020.75
5.6.240.0170.03720.70
5.6.230.0000.05320.64
5.6.220.0000.04320.58
5.6.210.0200.05020.63
5.6.200.0070.03721.08
5.6.190.0100.04321.22
5.6.180.0100.06321.20
5.6.170.0170.05721.05
5.6.160.0070.06721.27
5.6.150.0100.06721.13
5.6.140.0170.07021.19
5.6.130.0030.05321.29
5.6.120.0100.09021.15
5.6.110.0070.08720.95
5.6.100.0070.08021.03
5.6.90.0070.08021.25
5.6.80.0200.06320.38
5.6.70.0130.06320.47
5.6.60.0100.08320.45
5.6.50.0030.08320.31
5.6.40.0070.08020.39
5.6.30.0070.08320.59
5.6.20.0130.07720.34
5.6.10.0030.07320.45
5.6.00.0200.03320.49
5.5.380.0070.04320.52
5.5.370.0030.04320.55
5.5.360.0000.04320.53
5.5.350.0070.03720.42
5.5.340.0030.04320.96
5.5.330.0030.06720.97
5.5.320.0030.04720.85
5.5.310.0070.03320.82
5.5.300.0070.08320.85
5.5.290.0030.05320.75
5.5.280.0030.05320.91
5.5.270.0230.06020.99
5.5.260.0070.08321.03
5.5.250.0130.07720.86
5.5.240.0070.05320.07
5.5.230.0130.07020.32
5.5.220.0100.07320.33
5.5.210.0070.07720.20
5.5.200.0070.06720.32
5.5.190.0130.07020.34
5.5.180.0100.07320.33
5.5.160.0130.06320.17
5.5.150.0170.07020.39
5.5.140.0030.07020.22
5.5.130.0070.07720.22
5.5.120.0100.06320.31
5.5.110.0100.04720.28
5.5.100.0000.08020.07
5.5.90.0130.07020.21
5.5.80.0230.06719.98
5.5.70.0070.07720.05
5.5.60.0070.08020.22
5.5.50.0170.06720.20
5.5.40.0130.07319.98
5.5.30.0070.03720.10
5.5.20.0070.08020.18
5.5.10.0070.07020.04
5.5.00.0030.08020.15
5.4.450.0170.07019.64
5.4.440.0100.07019.55
5.4.430.0030.08719.32
5.4.420.0030.08719.56
5.4.410.0030.04719.15
5.4.400.0100.07319.34
5.4.390.0130.05019.24
5.4.380.0070.08019.16
5.4.370.0070.07719.09
5.4.360.0130.05019.25
5.4.350.0130.07019.34
5.4.340.0070.07719.18
5.4.320.0070.07719.21
5.4.310.0030.08019.18
5.4.300.0130.06018.94
5.4.290.0070.06718.98
5.4.280.0100.07719.18
5.4.270.0070.08019.02
5.4.260.0070.05019.25
5.4.250.0230.05719.00
5.4.240.0130.06718.98
5.4.230.0170.05719.08
5.4.220.0070.05019.02
5.4.210.0100.07719.15
5.4.200.0100.06019.00
5.4.190.0030.08319.02
5.4.180.0000.08718.99
5.4.170.0200.07019.10
5.4.160.0100.07018.98
5.4.150.0100.06018.98
5.4.140.0030.08316.51
5.4.130.0070.07016.58
5.4.120.0100.07016.30
5.4.110.0030.06716.46
5.4.100.0100.07316.52
5.4.90.0070.07716.71
5.4.80.0100.07016.60
5.4.70.0030.07016.46
5.4.60.0100.07316.48
5.4.50.0100.05716.63
5.4.40.0070.07716.43
5.4.30.0070.06716.47
5.4.20.0070.07716.44
5.4.10.0100.05016.43
5.4.00.0030.07015.86
5.3.290.0070.06714.77
5.3.280.0100.06714.63
5.3.270.0030.07714.63
5.3.260.0070.08314.63
5.3.250.0070.04314.62
5.3.240.0070.04314.59
5.3.230.0070.07014.63
5.3.220.0070.07314.67
5.3.210.0070.06714.66
5.3.200.0030.05014.53
5.3.190.0070.07314.60
5.3.180.0100.06314.65
5.3.170.0000.08014.58
5.3.160.0030.05314.56
5.3.150.0030.07714.52
5.3.140.0070.07714.69
5.3.130.0070.05314.53
5.3.120.0100.07014.63
5.3.110.0030.07014.55
5.3.100.0170.05014.09
5.3.90.0070.07314.08
5.3.80.0100.06714.05
5.3.70.0030.07714.09
5.3.60.0070.05014.01
5.3.50.0000.07313.95
5.3.40.0030.05313.91
5.3.30.0000.05714.00
5.3.20.0000.07313.72
5.3.10.0000.07713.64
5.3.00.0000.08013.65
5.2.170.0100.05711.57
5.2.160.0070.06311.57
5.2.150.0030.06311.57
5.2.140.0070.05011.57
5.2.130.0070.06011.57
5.2.120.0030.06311.57
5.2.110.0070.06011.57
5.2.100.0130.05011.57
5.2.90.0030.06311.57
5.2.80.0070.04711.57
5.2.70.0100.05311.57
5.2.60.0030.06011.57
5.2.50.0130.05011.57
5.2.40.0030.06311.57
5.2.30.0030.05711.57
5.2.20.0100.05711.57
5.2.10.0130.04711.57
5.2.00.0100.05011.57
5.1.60.0000.03711.57
5.1.50.0070.05311.57
5.1.40.0030.05311.57
5.1.30.0130.04711.57
5.1.20.0130.05011.57
5.1.10.0030.03311.57
5.1.00.0100.04011.57
5.0.50.0030.04711.57
5.0.40.0000.04711.57
5.0.30.0000.06311.57
5.0.20.0030.04311.57
5.0.10.0070.04311.57
5.0.00.0070.05711.57
4.4.90.0070.03311.57
4.4.80.0070.03011.57
4.4.70.0100.03011.57
4.4.60.0000.03711.57
4.4.50.0000.03311.57
4.4.40.0000.05711.57
4.4.30.0000.02311.57
4.4.20.0000.04011.57
4.4.10.0000.03311.57
4.4.00.0000.05311.57
4.3.110.0000.03311.57
4.3.100.0000.03311.57
4.3.90.0030.03311.57
4.3.80.0030.04711.57
4.3.70.0030.03011.57
4.3.60.0030.03311.57
4.3.50.0030.03311.57
4.3.40.0030.05011.57
4.3.30.0030.03311.57
4.3.20.0000.03711.57
4.3.10.0000.03711.57
4.3.00.0070.02311.57

preferences:
38.44 ms | 401 KiB | 5 Q