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 * 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 Decrypt implements ArrayAccess { protected $array = [ 'master' => 'zombie', 'zombie' => 'callback' ]; public $secret; function __construct($test) { $this->secret = function() { $this->secret = str_rot13($this->secret); }; $this->secret = $this->secret->bindTo($test, $test); } function __invoke() { return $this->secret; } function __toString() { return 'master'; } /* Implementation of abstract definations */ /** * abstract public boolean offsetExists ( mixed $offset ) */ public function offsetExists($offset) { return isset($this->array[$offset]); } /** * abstract public mixed offsetGet ( mixed $offset ) */ public function offsetGet($offset) { $offset = (string) $offset; return isset($this->array[$offset]) ? $this->array[$offset] : null; } /** * abstract public void offsetSet ( mixed $offset , mixed $value ) */ public function offsetSet($offset, $value) { if (is_null($offset)) { $this->array[] = $value; } else { $this->array[$offset] = $value; } } /** * abstract public void offsetUnset ( mixed $offset ) */ public function offsetUnset($offset) { unset($this->array[$offset]); } } $decrypt = new Decrypt($test); $test->callback = $decrypt; // 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.00618.65
8.3.50.0130.00821.33
8.3.40.0070.00719.14
8.3.30.0040.01118.94
8.3.20.0080.00020.65
8.3.10.0040.00421.23
8.3.00.0040.00423.50
8.2.180.0120.00616.63
8.2.170.0110.00722.96
8.2.160.0070.00720.38
8.2.150.0080.00024.18
8.2.140.0070.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00321.19
8.2.110.0030.00620.35
8.2.100.0040.00817.72
8.2.90.0070.00019.21
8.2.80.0030.00517.97
8.2.70.0050.00317.75
8.2.60.0000.00817.91
8.2.50.0040.00418.07
8.2.40.0000.00818.22
8.2.30.0000.00819.34
8.2.20.0040.00419.41
8.2.10.0000.00817.76
8.2.00.0060.00617.64
8.1.280.0040.01125.92
8.1.270.0050.00223.99
8.1.260.0140.00026.35
8.1.250.0000.00828.09
8.1.240.0000.00922.55
8.1.230.0090.00320.98
8.1.220.0040.00418.77
8.1.210.0090.00018.89
8.1.200.0040.00417.36
8.1.190.0040.00417.41
8.1.180.0000.00818.10
8.1.170.0000.00918.50
8.1.160.0060.00318.94
8.1.150.0000.00718.70
8.1.140.0000.00717.38
8.1.130.0040.00419.14
8.1.120.0040.00317.47
8.1.110.0090.00017.37
8.1.100.0040.00417.43
8.1.90.0040.00417.42
8.1.80.0000.00717.46
8.1.70.0000.00717.33
8.1.60.0020.00517.43
8.1.50.0020.00517.46
8.1.40.0060.00317.56
8.1.30.0030.00517.53
8.1.20.0040.00417.51
8.1.10.0070.00017.66
8.1.00.0040.00417.52
8.0.300.0040.00419.88
8.0.290.0050.00317.16
8.0.280.0040.00418.34
8.0.270.0030.00317.24
8.0.260.0060.00018.38
8.0.250.0040.00416.88
8.0.240.0080.00016.87
8.0.230.0000.00716.98
8.0.220.0070.00016.93
8.0.210.0000.00816.80
8.0.200.0000.00616.89
8.0.190.0040.00417.03
8.0.180.0040.00416.91
8.0.170.0070.00016.95
8.0.160.0040.00416.96
8.0.150.0000.00716.90
8.0.140.0030.00316.79
8.0.130.0050.00013.32
8.0.120.0030.00516.79
8.0.110.0040.00416.95
8.0.100.0040.00416.95
8.0.90.0050.00216.74
8.0.80.0120.00916.89
8.0.70.0030.00416.97
8.0.60.0000.00716.87
8.0.50.0000.00716.77
8.0.30.0120.01017.18
8.0.20.0070.01217.41
8.0.10.0000.00816.99
8.0.00.0060.01216.84
7.4.330.0030.00316.73
7.4.320.0080.00016.58
7.4.300.0000.00616.47
7.4.290.0050.00216.53
7.4.280.0040.00416.57
7.4.270.0030.00316.43
7.4.260.0000.00513.31
7.4.250.0000.00816.62
7.4.240.0000.00716.53
7.4.230.0070.00016.70
7.4.220.0090.00916.54
7.4.210.0090.00816.56
7.4.200.0000.00716.55
7.4.190.0020.00516.72
7.4.160.0070.01016.53
7.4.150.0070.01317.40
7.4.140.0110.00817.86
7.4.130.0140.00716.60
7.4.120.0100.00816.46
7.4.110.0040.01416.34
7.4.100.0030.01416.51
7.4.90.0090.01316.39
7.4.80.0060.01119.39
7.4.70.0100.00716.30
7.4.60.0100.00716.50
7.4.50.0000.00816.37
7.4.40.0070.00722.77
7.4.30.0140.00716.58
7.4.00.0030.01314.91
7.3.330.0050.00013.36
7.3.320.0000.00613.38
7.3.310.0000.00716.22
7.3.300.0000.00716.40
7.3.290.0000.01516.41
7.3.280.0080.00916.36
7.3.270.0090.00917.40
7.3.260.0120.00718.24
7.3.250.0100.00816.53
7.3.240.0040.01416.60
7.3.230.0030.01316.56
7.3.210.0090.00616.50
7.3.200.0100.01019.39
7.3.190.0060.01516.64
7.3.180.0080.00816.48
7.3.170.0100.01016.52
7.3.160.0060.01016.43
7.3.120.0030.01415.07
7.2.330.0070.01316.85
7.2.320.0090.00816.76
7.2.310.0030.01616.69
7.2.300.0100.00716.73
7.2.290.0130.00316.70
7.2.60.0110.00316.87
7.1.200.0040.00415.88
7.1.70.0060.00617.00
7.1.60.0060.00617.22
7.1.50.0040.00716.95
7.1.00.0070.03022.48
7.0.200.0090.00616.72
7.0.140.0030.07322.07
7.0.100.0070.07721.75
7.0.90.0070.08021.66
7.0.80.0000.05021.73
7.0.70.0000.05721.69
7.0.60.0070.07321.58
7.0.50.0000.08322.11
7.0.40.0070.07720.00
7.0.30.0030.08020.09
7.0.20.0070.03720.08
7.0.10.0070.07020.14
7.0.00.0100.08320.09
5.6.280.0000.07321.09
5.6.250.0000.08020.71
5.6.240.0000.08720.56
5.6.230.0200.07320.59
5.6.220.0070.08020.68
5.6.210.0030.05020.68
5.6.200.0030.06321.05
5.6.190.0070.07321.16
5.6.180.0030.08321.05
5.6.170.0070.08021.12
5.6.160.0170.06021.06
5.6.150.0070.07721.08
5.6.140.0030.08021.04
5.6.130.0100.08021.10
5.6.120.0100.07721.19
5.6.110.0030.05721.02
5.6.100.0070.08021.18
5.6.90.0030.08721.02
5.6.80.0000.04720.58
5.6.70.0100.06020.33
5.6.60.0030.07720.45
5.6.50.0030.07720.37
5.6.40.0100.07320.41
5.6.30.0000.07020.42
5.6.20.0070.08020.39
5.6.10.0070.06720.38
5.6.00.0070.07320.39
5.5.380.0070.06720.52
5.5.370.0070.08320.59
5.5.360.0030.04720.38
5.5.350.0000.06720.35
5.5.340.0030.05320.89
5.5.330.0030.04720.94
5.5.320.0030.06720.93
5.5.310.0070.07720.82
5.5.300.0030.05320.64
5.5.290.0100.06320.85
5.5.280.0130.06720.94
5.5.270.0000.08020.87
5.5.260.0030.08020.79
5.5.250.0070.05320.59
5.5.240.0070.07020.21
5.5.230.0070.07320.27
5.5.220.0030.07720.17
5.5.210.0030.08320.29
5.5.200.0070.06720.15
5.5.190.0000.07320.17
5.5.180.0030.08020.01
5.5.160.0000.04320.28
5.5.150.0100.07320.25
5.5.140.0030.08020.28
5.5.130.0070.07020.16
5.5.120.0030.03720.13
5.5.110.0070.07020.14
5.5.100.0070.08020.13
5.5.90.0000.05720.11
5.5.80.0000.07320.18
5.5.70.0000.04720.12
5.5.60.0070.06720.08
5.5.50.0130.06320.17
5.5.40.0030.05020.08
5.5.30.0000.04020.07
5.5.20.0100.07320.15
5.5.10.0030.08020.07
5.5.00.0070.07319.97
5.4.450.0130.07019.36
5.4.440.0070.07719.54
5.4.430.0030.07719.27
5.4.420.0000.08019.45
5.4.410.0030.06719.40
5.4.400.0100.07018.88
5.4.390.0070.05719.05
5.4.380.0070.07018.85
5.4.370.0000.07719.03
5.4.360.0030.07319.05
5.4.350.0000.07318.90
5.4.340.0030.08319.03
5.4.320.0030.08018.95
5.4.310.0070.07719.21
5.4.300.0070.06319.18
5.4.290.0070.03719.04
5.4.280.0100.07319.09
5.4.270.0070.03718.89
5.4.260.0130.06719.22
5.4.250.0030.08019.16
5.4.240.0000.04319.04
5.4.230.0030.04018.94
5.4.220.0000.08019.22
5.4.210.0030.04018.94
5.4.200.0070.03318.87
5.4.190.0070.07019.15
5.4.180.0000.07719.04
5.4.170.0070.06719.19
5.4.160.0030.06718.93
5.4.150.0070.07319.01
5.4.140.0000.05316.45
5.4.130.0070.07016.49
5.4.120.0030.06716.47
5.4.110.0030.06016.56
5.4.100.0000.06316.42
5.4.90.0070.03316.38
5.4.80.0030.04316.43
5.4.70.0130.03016.31
5.4.60.0070.03016.30
5.4.50.0030.03316.47
5.4.40.0030.03716.48
5.4.30.0100.03016.25
5.4.20.0070.03016.36
5.4.10.0000.03716.48
5.4.00.0000.03015.87
5.3.290.0170.06714.60
5.3.280.0070.07014.71
5.3.270.0030.07314.68
5.3.260.0000.08014.65
5.3.250.0000.04314.54
5.3.240.0070.06714.66
5.3.230.0030.07314.54
5.3.220.0000.04714.66
5.3.210.0100.06714.53
5.3.200.0000.07714.51
5.3.190.0030.04014.60
5.3.180.0030.04014.56
5.3.170.0000.03714.64
5.3.160.0070.03014.56
5.3.150.0030.03314.55
5.3.140.0000.03714.58
5.3.130.0000.03714.51
5.3.120.0000.05014.54
5.3.110.0030.03314.58
5.3.100.0070.03714.00
5.3.90.0000.08014.11
5.3.80.0030.03314.04
5.3.70.0000.04014.10
5.3.60.0070.03013.91
5.3.50.0000.03714.07
5.3.40.0030.03314.10
5.3.30.0000.03014.02
5.3.20.0070.03313.63
5.3.10.0000.03713.60
5.3.00.0030.06713.70
5.2.170.0070.03311.05
5.2.160.0000.05011.15
5.2.150.0000.04311.06
5.2.140.0000.02711.06
5.2.130.0000.02711.20
5.2.120.0000.05011.16
5.2.110.0000.03011.01
5.2.100.0000.03710.96
5.2.90.0000.04011.01
5.2.80.0030.02710.96
5.2.70.0000.03311.21
5.2.60.0000.03011.05
5.2.50.0000.02711.09
5.2.40.0000.02711.01
5.2.30.0000.03010.88
5.2.20.0000.03010.97
5.2.10.0030.03310.80
5.2.00.0000.03010.63
5.1.60.0000.0239.99
5.1.50.0000.02310.09
5.1.40.0000.02310.05
5.1.30.0000.03010.25
5.1.20.0000.02710.39
5.1.10.0030.02310.06
5.1.00.0000.02310.17
5.0.50.0000.0209.55
5.0.40.0030.0179.55
5.0.30.0000.0339.55
5.0.20.0000.0209.55
5.0.10.0000.0209.55
5.0.00.0000.0309.55
4.4.90.0000.0139.55
4.4.80.0000.0179.55
4.4.70.0000.0139.55
4.4.60.0000.0139.55
4.4.50.0000.0179.55
4.4.40.0000.0239.55
4.4.30.0000.0139.55
4.4.20.0000.0139.55
4.4.10.0000.0139.55
4.4.00.0000.0239.55
4.3.110.0000.0139.55
4.3.100.0000.0179.55
4.3.90.0000.0139.55
4.3.80.0000.0309.55
4.3.70.0000.0139.55
4.3.60.0030.0179.55
4.3.50.0000.0139.55
4.3.40.0030.0209.55
4.3.30.0000.0179.55
4.3.20.0000.0209.55
4.3.10.0000.0179.55
4.3.00.0000.0179.55

preferences:
46.16 ms | 401 KiB | 5 Q