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 2"; }; 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.0080.00822.11
8.3.40.0140.00318.69
8.3.30.0140.00019.17
8.3.20.0040.00420.34
8.3.10.0080.00023.47
8.3.00.0080.00019.38
8.2.180.0180.00416.75
8.2.170.0040.01122.96
8.2.160.0120.00620.52
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0090.00626.16
8.2.120.0040.00419.78
8.2.110.0060.00322.17
8.2.100.0040.00817.91
8.2.90.0040.00419.10
8.2.80.0030.00617.97
8.2.70.0030.00517.62
8.2.60.0050.00318.05
8.2.50.0030.00618.07
8.2.40.0040.00420.01
8.2.30.0030.00518.21
8.2.20.0000.00817.76
8.2.10.0000.00818.05
8.2.00.0000.01017.76
8.1.280.0140.00325.92
8.1.270.0030.00522.20
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0000.01023.88
8.1.230.0030.00918.94
8.1.220.0000.00817.79
8.1.210.0000.00818.77
8.1.200.0040.00717.35
8.1.190.0040.00417.41
8.1.180.0030.00618.10
8.1.170.0000.00818.63
8.1.160.0000.00721.95
8.1.150.0000.01018.62
8.1.140.0040.00417.55
8.1.130.0030.00317.91
8.1.120.0040.00417.50
8.1.110.0040.00417.39
8.1.100.0030.00317.47
8.1.90.0040.00317.51
8.1.80.0040.00417.52
8.1.70.0060.00317.45
8.1.60.0040.00417.60
8.1.50.0000.00817.52
8.1.40.0030.00617.58
8.1.30.0040.00417.61
8.1.20.0040.00417.71
8.1.10.0030.00517.47
8.1.00.0050.00317.47
8.0.300.0040.00420.87
8.0.290.0000.00717.04
8.0.280.0030.00318.46
8.0.270.0000.00717.28
8.0.260.0000.00617.20
8.0.250.0000.00717.02
8.0.240.0070.00016.97
8.0.230.0000.00817.04
8.0.220.0070.00016.87
8.0.210.0000.00716.89
8.0.200.0000.00616.96
8.0.190.0040.00416.98
8.0.180.0000.00716.86
8.0.170.0040.00416.93
8.0.160.0040.00416.86
8.0.150.0070.00016.90
8.0.140.0030.00516.75
8.0.130.0050.00013.36
8.0.120.0050.00316.95
8.0.110.0050.00316.83
8.0.100.0000.00716.75
8.0.90.0040.00416.90
8.0.80.0130.00316.83
8.0.70.0000.00716.96
8.0.60.0040.00416.77
8.0.50.0000.00717.02
8.0.30.0090.01017.13
8.0.20.0100.00817.40
8.0.10.0030.00417.11
8.0.00.0050.01216.86
7.4.330.0030.00315.00
7.4.320.0030.00316.52
7.4.300.0030.00316.64
7.4.290.0030.00316.55
7.4.280.0050.00316.46
7.4.270.0070.00016.62
7.4.260.0040.00416.54
7.4.250.0070.00016.39
7.4.240.0020.00516.65
7.4.230.0000.00716.41
7.4.220.0090.00916.72
7.4.210.0040.01116.66
7.4.200.0050.00216.73
7.4.190.0000.00716.50
7.4.160.0030.01316.36
7.4.150.0060.01117.40
7.4.140.0100.00717.86
7.4.130.0110.00716.50
7.4.120.0130.01016.50
7.4.110.0100.00716.45
7.4.100.0070.01116.46
7.4.90.0070.01116.48
7.4.80.0100.01319.39
7.4.70.0000.02316.55
7.4.60.0140.00716.44
7.4.50.0000.00516.32
7.4.40.0100.00522.77
7.4.30.0090.00616.59
7.4.00.0090.00615.09
7.3.330.0000.00613.24
7.3.320.0000.00713.40
7.3.310.0030.00516.41
7.3.300.0000.00916.33
7.3.290.0130.00616.34
7.3.280.0100.01016.40
7.3.270.0100.00617.40
7.3.260.0170.00716.59
7.3.250.0080.01016.46
7.3.240.0070.01016.45
7.3.230.0070.01416.39
7.3.210.0130.00316.56
7.3.200.0100.01019.39
7.3.190.0150.00316.59
7.3.180.0100.00616.32
7.3.170.0090.00616.42
7.3.160.0070.01016.57
7.3.120.0090.00714.93
7.3.110.0050.01014.78
7.3.100.0070.00714.64
7.3.90.0050.00915.00
7.3.80.0040.00914.96
7.3.70.0100.00415.00
7.3.60.0060.00714.59
7.3.50.0080.00614.72
7.3.40.0040.00914.85
7.3.30.0040.00914.71
7.3.20.0090.00516.79
7.3.10.0120.00316.60
7.3.00.0040.00816.52
7.2.330.0100.00816.77
7.2.320.0110.00716.77
7.2.310.0030.01316.46
7.2.300.0070.01016.84
7.2.290.0070.01016.72
7.2.250.0070.01015.11
7.2.240.0090.00515.19
7.2.230.0020.01215.08
7.2.220.0050.01115.10
7.2.210.0070.00914.89
7.2.200.0060.00814.96
7.2.190.0050.01115.11
7.2.180.0100.00715.07
7.2.170.0060.00915.17
7.2.160.0040.01115.13
7.2.150.0030.01317.02
7.2.140.0120.00316.79
7.2.130.0040.01016.97
7.2.120.0100.00516.97
7.2.110.0030.00916.86
7.2.100.0060.00816.78
7.2.90.0050.01016.90
7.2.80.0070.01116.90
7.2.70.0060.00516.71
7.2.60.0100.00516.86
7.2.50.0030.01017.05
7.2.40.0030.00916.66
7.2.30.0110.00916.90
7.2.20.0070.00916.85
7.2.10.0050.01016.76
7.2.00.0070.00817.82
7.1.330.0020.01215.75
7.1.320.0020.01215.71
7.1.310.0060.00615.98
7.1.300.0060.00615.98
7.1.290.0070.00715.96
7.1.280.0020.01415.84
7.1.270.0050.00615.81
7.1.260.0050.00815.82
7.1.250.0030.01115.79
7.1.100.0060.00918.12
7.1.70.0050.00517.20
7.1.60.0100.00719.46
7.1.50.0080.01116.89
7.1.00.0070.07322.44
7.0.200.0000.00816.89
7.0.140.0100.06722.02
7.0.60.0070.08020.04
7.0.50.0130.05317.90
7.0.40.0030.09020.40
7.0.30.0300.04720.11
7.0.20.0230.04320.30
7.0.10.0070.07720.25
7.0.00.0100.06720.18
5.6.280.0000.07321.01
5.6.210.0100.06320.68
5.6.200.0070.03718.19
5.6.190.0070.08720.52
5.6.180.0170.09020.33
5.6.170.0300.07720.48
5.6.160.0000.06320.61
5.6.150.0130.07718.26
5.6.140.0030.04318.26
5.6.130.0070.06718.16
5.6.120.0130.04321.12
5.6.110.0030.04021.03
5.6.100.0070.09321.11
5.6.90.0000.04721.12
5.6.80.0100.05320.55
5.6.70.4430.03320.55
5.5.350.0200.04020.46
5.5.340.0070.04718.04
5.5.330.0100.07720.41
5.5.320.0130.04720.35
5.5.310.0370.07320.32
5.5.300.0070.06318.00
5.5.290.0100.07717.95
5.5.280.0100.08320.82
5.5.270.0070.08020.91
5.5.260.0270.06720.77
5.5.250.0070.05320.60
5.5.240.4170.03720.28
5.4.450.0700.06319.61
5.4.440.0670.07019.53
5.4.430.0400.05319.30
5.4.420.0800.06319.54
5.4.410.0870.06319.33
5.4.400.0830.05319.16
5.4.390.0670.05719.00
5.4.380.0300.05018.77
5.4.370.0330.05018.74
5.4.360.0300.05018.81
5.4.350.0370.04318.49
5.4.340.0370.05018.80
5.4.320.0070.03512.52
5.4.310.0080.03912.52
5.4.300.0060.04112.52
5.4.290.0090.05712.50
5.4.280.0150.06112.39
5.4.270.0060.05312.39
5.4.260.0080.04512.39
5.4.250.0090.04312.39
5.4.240.0090.05012.40
5.4.230.0040.05212.38
5.4.220.0090.05212.39
5.4.210.0080.06312.38
5.4.200.0070.05512.39
5.4.190.0070.05312.38
5.4.180.0120.04812.38
5.4.170.0070.05612.39
5.4.160.0050.05212.39
5.4.150.0090.04912.38
5.4.140.0070.05512.07
5.4.130.0070.05112.06
5.4.120.0070.05412.02
5.4.110.0080.05112.01
5.4.100.0080.04212.01
5.4.90.0060.04812.01
5.4.80.0090.05112.01
5.4.70.0090.05412.00
5.4.60.0090.05412.00
5.4.50.0140.08612.01
5.4.40.0080.06212.00
5.4.30.0100.06111.99
5.4.20.0070.04511.99
5.4.10.0050.04211.99
5.4.00.0080.04711.47
5.3.290.0100.04112.80
5.3.280.0110.04012.71
5.3.270.0070.04612.72
5.3.260.0080.04212.72
5.3.250.0120.04012.72
5.3.240.0090.04112.72
5.3.230.0110.05712.71
5.3.220.0120.12712.68
5.3.210.0160.12112.68
5.3.200.0160.10912.68
5.3.190.0140.10612.67
5.3.180.0100.05712.67
5.3.170.0200.06912.67
5.3.160.0070.05012.67
5.3.150.0070.05712.68
5.3.140.0080.04512.66
5.3.130.0130.04612.66
5.3.120.0060.04112.66
5.3.110.0040.04212.65
5.3.100.0050.04112.13
5.3.90.0070.05112.12
5.3.80.0060.05812.11
5.3.70.0050.05512.11
5.3.60.0050.05112.10
5.3.50.0060.03812.04
5.3.40.0080.03712.04
5.3.30.0030.04312.00
5.3.20.0090.04311.78
5.3.10.0070.03611.75
5.3.00.0060.04111.73
5.2.170.0050.0359.23
5.2.160.0090.0399.23
5.2.150.0070.0429.23
5.2.140.0150.0349.23
5.2.130.0060.0339.19
5.2.120.0030.0319.18
5.2.110.0050.0299.20
5.2.100.0050.0319.20
5.2.90.0030.0339.20
5.2.80.0070.0359.19
5.2.70.0040.0399.19
5.2.60.0130.0659.14
5.2.50.0070.0409.11
5.2.40.0070.0319.09
5.2.30.0130.0419.06
5.2.20.0070.0319.05
5.2.10.0110.0408.95
5.2.00.0050.0438.82
5.1.60.0070.0288.10
5.1.50.0070.0348.10
5.1.40.0080.0918.08
5.1.30.0030.0328.43
5.1.20.0050.0278.45
5.1.10.0040.0288.18
5.1.00.0020.0298.18
5.0.50.0030.0276.66
5.0.40.0040.0266.52
5.0.30.0040.0336.33
5.0.20.0020.0256.30
5.0.10.0030.0256.28
5.0.00.0040.0326.27
4.4.90.0010.0184.78
4.4.80.0050.0164.75
4.4.70.0010.0194.76
4.4.60.0040.0224.76
4.4.50.0040.0224.77
4.4.40.0050.0334.71
4.4.30.0060.0144.76
4.4.20.0030.0234.84
4.4.10.0020.0164.85
4.4.00.0040.0254.76
4.3.110.0030.0234.67
4.3.100.0030.0224.67
4.3.90.0080.0144.64
4.3.80.0040.0334.58
4.3.70.0020.0244.63
4.3.60.0070.0284.63
4.3.50.0060.0234.63
4.3.40.0040.0354.54
4.3.30.0050.0223.30
4.3.20.0020.0183.28
4.3.10.0020.0243.23
4.3.00.0170.01310.54

preferences:
38.64 ms | 401 KiB | 5 Q