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 $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here class Solution extends ArrayObject { public function __construct($test){ $this->test = $test; } public function offsetGet($index) { return 'callback'; } public function __invoke(){ $func = function(){ $this->secret = "ALL YOUR BASE ARE BELONG TO US"; }; return $func->bindTo($this->test, 'Test'); } } $v = new Solution($test); $test->callback = $v; // 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.0120.00316.88
8.3.50.0130.00721.95
8.3.40.0120.00618.82
8.3.30.0090.00619.16
8.3.20.0050.00220.30
8.3.10.0080.00023.63
8.3.00.0100.01019.38
8.2.180.0090.00916.63
8.2.170.0070.00722.96
8.2.160.0060.00820.35
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0120.00626.16
8.2.120.0040.00422.26
8.2.110.0030.00622.11
8.2.100.0040.00718.34
8.2.90.0070.00319.20
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0030.00618.10
8.2.40.0000.00820.55
8.2.30.0000.00719.38
8.2.20.0000.00717.77
8.2.10.0000.00818.20
8.2.00.0080.00417.67
8.1.280.0140.00025.92
8.1.270.0080.00022.10
8.1.260.0140.00726.35
8.1.250.0040.00428.09
8.1.240.0000.00920.91
8.1.230.0120.00019.09
8.1.220.0000.00817.78
8.1.210.0030.00518.77
8.1.200.0030.00617.48
8.1.190.0080.00017.25
8.1.180.0000.00720.14
8.1.170.0000.00818.57
8.1.160.0050.00218.95
8.1.150.0050.00220.17
8.1.140.0040.00417.42
8.1.130.0030.00317.89
8.1.120.0050.00317.48
8.1.110.0070.00417.38
8.1.100.0050.00217.38
8.1.90.0050.00217.35
8.1.80.0000.00717.54
8.1.70.0030.00317.36
8.1.60.0030.00617.46
8.1.50.0040.00417.58
8.1.40.0040.00417.51
8.1.30.0090.00017.62
8.1.20.0000.00717.64
8.1.10.0080.00017.48
8.1.00.0000.00817.55
8.0.300.0040.00418.77
8.0.290.0070.00016.63
8.0.280.0000.00718.39
8.0.270.0030.00317.29
8.0.260.0000.00617.28
8.0.250.0060.00316.97
8.0.240.0000.00716.96
8.0.230.0040.00416.94
8.0.220.0030.00316.79
8.0.210.0060.00316.80
8.0.200.0040.00416.99
8.0.190.0060.00316.94
8.0.180.0080.00016.96
8.0.170.0000.00817.00
8.0.160.0030.00316.87
8.0.150.0020.00516.91
8.0.140.0040.00416.85
8.0.130.0000.00913.27
8.0.120.0080.00016.77
8.0.110.0040.00416.87
8.0.100.0060.00316.79
8.0.90.0040.00416.73
8.0.80.0130.00316.88
8.0.70.0000.00816.74
8.0.60.0040.00416.94
8.0.50.0000.00716.87
8.0.30.0080.01317.10
8.0.20.0160.00317.40
8.0.10.0040.00416.96
8.0.00.0080.01016.77
7.4.330.0000.00515.00
7.4.320.0000.00716.58
7.4.300.0000.00616.54
7.4.290.0000.00816.62
7.4.280.0000.00716.57
7.4.270.0040.00416.52
7.4.260.0040.00416.43
7.4.250.0070.00016.48
7.4.240.0000.00816.48
7.4.230.0000.00716.38
7.4.220.0070.01416.57
7.4.210.0050.00916.65
7.4.200.0040.00416.52
7.4.190.0000.00716.51
7.4.160.0120.00316.44
7.4.150.0030.01317.40
7.4.140.0140.00417.86
7.4.130.0060.01216.48
7.4.120.0060.01316.56
7.4.110.0090.01516.56
7.4.100.0130.01016.43
7.4.90.0210.00416.42
7.4.80.0180.00319.39
7.4.70.0150.00916.54
7.4.60.0110.00816.42
7.4.50.0090.00016.54
7.4.40.0100.00322.77
7.4.30.0000.02316.50
7.4.00.0030.01315.11
7.3.330.0050.00313.33
7.3.320.0030.00313.10
7.3.310.0070.00016.40
7.3.300.0070.00016.38
7.3.290.0040.01116.36
7.3.280.0080.00916.37
7.3.270.0030.01317.40
7.3.260.0090.00916.57
7.3.250.0130.00516.57
7.3.240.0100.00716.58
7.3.230.0090.00916.45
7.3.210.0000.01816.55
7.3.200.0100.00719.39
7.3.190.0060.01616.57
7.3.180.0160.00016.56
7.3.170.0060.01016.50
7.3.160.0070.01016.36
7.3.120.0050.01014.92
7.3.110.0040.01414.72
7.3.100.0090.00615.03
7.3.90.0060.01214.81
7.3.80.0070.01114.51
7.3.70.0090.00914.78
7.3.60.0030.00914.69
7.3.50.0030.01614.92
7.3.40.0030.01414.61
7.3.30.0100.00315.00
7.3.20.0030.01216.72
7.3.10.0070.00716.66
7.3.00.0120.00316.80
7.2.330.0130.00616.44
7.2.320.0120.00616.85
7.2.310.0070.01016.65
7.2.300.0120.00616.82
7.2.290.0030.01416.84
7.2.250.0060.01215.25
7.2.240.0030.01615.36
7.2.230.0070.01315.00
7.2.220.0060.01215.25
7.2.210.0100.01014.94
7.2.200.0070.00715.29
7.2.190.0060.00915.07
7.2.180.0110.00714.95
7.2.170.0110.00715.16
7.2.00.0090.00619.45
7.1.330.0080.00416.07
7.1.320.0070.01115.89
7.1.310.0080.00315.74
7.1.300.0100.00715.94
7.1.290.0030.01415.82
7.1.280.0030.01015.70
7.1.270.0090.00315.80
7.1.260.0070.01016.01
7.1.100.0110.01117.90
7.1.70.0040.00416.93
7.1.60.0120.01219.46
7.1.50.0130.00916.93
7.1.00.0000.08022.35
7.0.200.0030.00716.58
7.0.140.0030.07322.12
7.0.60.0070.08019.95
7.0.50.0030.07317.99
7.0.40.0070.04020.24
7.0.30.0130.04720.23
7.0.20.0100.04720.19
7.0.10.0200.07720.06
7.0.00.0070.08320.09
5.6.280.0070.09021.09
5.6.210.0100.08320.72
5.6.200.0070.08318.14
5.6.190.0030.05020.41
5.6.180.0300.04020.49
5.6.170.0400.04320.45
5.6.160.0030.04320.61
5.6.150.0100.08318.27
5.6.140.0070.04318.18
5.6.130.0100.07718.28
5.6.120.0100.06721.04
5.6.110.0100.07020.91
5.6.100.0030.08721.00
5.6.90.0000.06320.89
5.6.80.0100.06720.54
5.6.70.4700.03020.54
5.5.350.0070.07020.35
5.5.340.0070.03717.95
5.5.330.0030.07020.26
5.5.320.0270.06020.34
5.5.310.0270.08320.30
5.5.300.0070.07318.08
5.5.290.0030.05717.94
5.5.280.0030.07720.66
5.5.270.0130.07720.90
5.5.260.0000.09020.99
5.5.250.0170.07020.60
5.5.240.0030.06720.20
5.4.450.0800.05019.55
5.4.440.0770.05319.15
5.4.430.0670.05719.48
5.4.420.0870.06019.47
5.4.410.1000.05719.03
5.4.400.0130.05019.27
5.4.390.0770.05719.24
5.4.380.0270.06018.58
5.4.370.0330.06718.79
5.4.360.0300.06018.54
5.4.350.0400.07718.55
5.4.340.0300.05318.55
5.4.320.0080.03712.52
5.4.310.0060.04212.52
5.4.300.0080.03712.52
5.4.290.0070.03812.50
5.4.280.0050.03812.39
5.4.270.0050.03912.39
5.4.260.0090.03712.39
5.4.250.0080.03812.39
5.4.240.0110.03512.39
5.4.230.0040.04212.39
5.4.220.0100.03412.38
5.4.210.0080.03912.39
5.4.200.0120.03912.39
5.4.190.0060.05312.38
5.4.180.0080.04812.38
5.4.170.0060.04012.39
5.4.160.0060.03912.39
5.4.150.0070.04012.38
5.4.140.0120.03412.07
5.4.130.0060.04512.06
5.4.120.0060.04112.01
5.4.110.0040.04512.01
5.4.100.0070.03512.01
5.4.90.0080.05112.01
5.4.80.0090.04912.01
5.4.70.0130.05612.00
5.4.60.0050.04212.00
5.4.50.0110.03612.01
5.4.40.0100.04611.99
5.4.30.0070.04111.99
5.4.20.0090.04811.99
5.4.10.0070.05111.99
5.4.00.0080.06411.48
5.3.290.0070.04212.80
5.3.280.0120.05812.71
5.3.270.0110.05812.72
5.3.260.0090.04212.72
5.3.250.0120.03512.72
5.3.240.0060.04612.72
5.3.230.0060.04112.71
5.3.220.0050.04812.68
5.3.210.0060.06212.68
5.3.200.0060.05512.68
5.3.190.0100.05112.67
5.3.180.0060.05512.68
5.3.170.0180.13912.67
5.3.160.0080.05312.68
5.3.150.0070.05512.67
5.3.140.0080.05312.66
5.3.130.0090.05512.65
5.3.120.0340.11112.66
5.3.110.0140.07112.66
5.3.100.0260.05312.13
5.3.90.0220.07812.12
5.3.80.0110.05112.11
5.3.70.0140.04512.11
5.3.60.0090.05512.09
5.3.50.0110.04912.04
5.3.40.0130.05312.04
5.3.30.0140.05112.00
5.3.20.0110.07311.79
5.3.10.0090.05511.75
5.3.00.0060.04211.73
5.2.170.0070.0329.23
5.2.160.0090.0319.23
5.2.150.0070.0389.23
5.2.140.0080.0339.22
5.2.130.0030.0329.19
5.2.120.0090.0269.18
5.2.110.0030.0309.20
5.2.100.0040.0289.20
5.2.90.0040.0359.19
5.2.80.0050.0319.19
5.2.70.0060.0309.19
5.2.60.0050.0319.14
5.2.50.0050.0309.12
5.2.40.0070.0289.09
5.2.30.0070.0329.06
5.2.20.0060.0319.05
5.2.10.0060.0298.96
5.2.00.0080.0268.82
5.1.60.0050.0238.11
5.1.50.0070.0238.10
5.1.40.0040.0258.08
5.1.30.0050.0268.44
5.1.20.0060.0378.45
5.1.10.0060.0358.18
5.1.00.0080.0248.18
5.0.50.0060.0216.66
5.0.40.0070.0196.52
5.0.30.0090.0436.32
5.0.20.0100.0416.30
5.0.10.0060.0286.28
5.0.00.0260.0806.27
4.4.90.0060.0274.78
4.4.80.0040.0224.76
4.4.70.0050.0204.75
4.4.60.0040.0204.76
4.4.50.0050.0234.77
4.4.40.0040.0394.70
4.4.30.0030.0244.76
4.4.20.0070.0214.84
4.4.10.0040.0164.85
4.4.00.0060.0314.76
4.3.110.0030.0214.67
4.3.100.0020.0234.66
4.3.90.0060.0194.64
4.3.80.0070.0284.59
4.3.70.0040.0174.63
4.3.60.0040.0214.63
4.3.50.0020.0214.63
4.3.40.0060.0284.54
4.3.30.0020.0223.30
4.3.20.0020.0233.28
4.3.10.0020.0173.23
4.3.00.0000.01710.54

preferences:
44.48 ms | 401 KiB | 5 Q