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 { 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; } /* 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.0070.01418.68
8.3.50.0070.00921.99
8.3.40.0080.00818.97
8.3.30.0040.01118.88
8.3.20.0040.00418.95
8.3.10.0000.00921.21
8.3.00.0050.00323.48
8.2.180.0100.00716.63
8.2.170.0110.00422.96
8.2.160.0100.00720.43
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0120.00619.58
8.2.110.0070.00320.35
8.2.100.0060.00617.97
8.2.90.0040.00419.35
8.2.80.0070.00019.39
8.2.70.0060.00317.63
8.2.60.0040.00418.16
8.2.50.0000.00918.07
8.2.40.0060.00318.16
8.2.30.0060.00319.51
8.2.20.0000.00817.80
8.2.10.0000.00817.82
8.2.00.0080.00017.88
8.1.280.0040.01125.92
8.1.270.0000.00823.99
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0000.00922.65
8.1.230.0060.00620.97
8.1.220.0050.00318.77
8.1.210.0050.00518.77
8.1.200.0000.00917.25
8.1.190.0040.00417.53
8.1.180.0050.00318.10
8.1.170.0000.00818.53
8.1.160.0040.00418.90
8.1.150.0080.00018.53
8.1.140.0070.00017.50
8.1.130.0000.00717.84
8.1.120.0070.00017.46
8.1.110.0040.00417.50
8.1.100.0070.00017.48
8.1.90.0050.00217.45
8.1.80.0070.00017.31
8.1.70.0040.00417.42
8.1.60.0060.00317.43
8.1.50.0000.00917.48
8.1.40.0000.00717.48
8.1.30.0000.00917.67
8.1.20.0000.00817.56
8.1.10.0030.00617.46
8.1.00.0080.00017.56
8.0.300.0030.00619.98
8.0.290.0070.00017.15
8.0.280.0040.00418.43
8.0.270.0000.00816.97
8.0.260.0000.00616.82
8.0.250.0000.00716.89
8.0.240.0000.00817.06
8.0.230.0030.00317.05
8.0.220.0100.00017.00
8.0.210.0000.00716.81
8.0.200.0030.00317.05
8.0.190.0080.00016.99
8.0.180.0070.00017.00
8.0.170.0040.00417.02
8.0.160.0080.00016.97
8.0.150.0040.00416.94
8.0.140.0030.00517.01
8.0.130.0050.00013.36
8.0.120.0050.00316.84
8.0.110.0080.00017.02
8.0.100.0000.00716.75
8.0.90.0040.00416.87
8.0.80.0060.00916.95
8.0.70.0030.00316.79
8.0.60.0040.00416.94
8.0.50.0040.00416.99
8.0.30.0150.00717.15
8.0.20.0120.01117.40
8.0.10.0000.00817.16
8.0.00.0100.00916.80
7.4.330.0000.00516.83
7.4.320.0070.00016.39
7.4.300.0000.00616.38
7.4.290.0030.00316.53
7.4.280.0080.00016.50
7.4.270.0070.00016.52
7.4.260.0050.00013.29
7.4.250.0070.00016.48
7.4.240.0000.00716.48
7.4.230.0000.00716.63
7.4.220.0140.01316.42
7.4.210.0100.00616.54
7.4.200.0070.00016.44
7.4.190.0000.00716.71
7.4.160.0060.01216.49
7.4.150.0090.00917.40
7.4.140.0130.00617.86
7.4.130.0080.00916.58
7.4.120.0090.00916.49
7.4.110.0060.01116.54
7.4.100.0150.00816.52
7.4.90.0150.00416.70
7.4.80.0120.00619.39
7.4.70.0000.01816.55
7.4.60.0090.00916.48
7.4.50.0000.00916.46
7.4.40.0020.00822.77
7.4.30.0100.01016.38
7.4.00.0060.01014.96
7.3.330.0060.00013.40
7.3.320.0000.00513.32
7.3.310.0030.00316.29
7.3.300.0000.00816.39
7.3.290.0060.00916.46
7.3.280.0120.00616.35
7.3.270.0150.00317.40
7.3.260.0110.01018.24
7.3.250.0120.00616.48
7.3.240.0130.00316.43
7.3.230.0100.00616.58
7.3.210.0130.01016.53
7.3.200.0110.00619.39
7.3.190.0030.01316.51
7.3.180.0040.01116.45
7.3.170.0060.01016.45
7.3.160.0070.00716.48
7.3.120.0100.00714.87
7.3.110.0070.01114.66
7.3.100.0030.01014.75
7.3.90.0030.00615.08
7.3.80.0130.00314.58
7.3.70.0040.01114.57
7.3.60.0090.00614.77
7.3.50.0000.01214.97
7.3.40.0070.01014.95
7.3.30.0090.00615.08
7.3.20.0000.01516.39
7.3.10.0070.00816.52
7.3.00.0090.00316.59
7.2.330.0070.01016.83
7.2.320.0160.00016.63
7.2.310.0070.01116.75
7.2.300.0090.00916.77
7.2.290.0070.01116.80
7.2.250.0120.00615.00
7.2.240.0070.01415.25
7.2.230.0130.00315.23
7.2.220.0130.00314.86
7.2.210.0100.00314.86
7.2.200.0060.00915.23
7.2.190.0070.00715.04
7.2.180.0090.00614.87
7.2.170.0030.01014.89
7.2.130.0070.00616.65
7.2.120.0070.00816.99
7.2.110.0110.00316.96
7.2.100.0060.00716.87
7.2.90.0030.01017.06
7.2.80.0050.00616.96
7.2.70.0080.00516.98
7.2.60.0050.01017.00
7.2.50.0060.00617.06
7.2.40.0070.00816.94
7.2.30.0070.00816.96
7.2.20.0110.00316.96
7.2.10.0070.00516.80
7.2.00.0060.00917.77
7.1.330.0040.01415.96
7.1.320.0000.01215.85
7.1.310.0090.00616.11
7.1.300.0030.00715.59
7.1.290.0030.00715.55
7.1.280.0060.00615.63
7.1.270.0030.00915.58
7.1.260.0110.00415.92
7.1.250.0070.00915.70
7.1.200.0050.00515.91
7.1.70.0070.00717.18
7.1.60.0030.01717.12
7.1.50.0100.01417.02
7.1.00.0000.05722.36
7.0.200.0060.01016.90
7.0.140.0000.07722.07
7.0.100.0130.04719.96
7.0.90.0100.04319.99
7.0.80.0030.06319.98
7.0.70.0170.07019.84
7.0.60.0300.07019.95
7.0.50.0030.05720.29
7.0.40.0130.07319.96
7.0.30.0030.06720.06
7.0.20.0030.04320.11
7.0.10.0100.05319.95
7.0.00.0030.07719.89
5.6.280.0030.07321.11
5.6.250.0000.04320.47
5.6.240.0030.04020.67
5.6.230.0070.04020.51
5.6.220.0070.04720.59
5.6.210.0000.05320.56
5.6.200.0100.08320.92
5.6.190.0030.06021.08
5.6.180.0130.05721.02
5.6.170.0030.05020.91
5.6.160.0030.08020.95
5.6.150.0030.05321.00
5.6.140.0130.04321.06
5.6.130.0030.08320.92
5.6.120.0170.05721.01
5.6.110.0000.05021.00
5.6.100.0130.07321.10
5.6.90.0030.05020.99
5.6.80.0100.05320.40
5.6.70.0170.03320.47
5.6.60.0200.06320.40
5.6.50.0070.08320.41
5.6.40.0070.07320.36
5.6.30.0070.06720.46
5.6.20.0130.07020.38
5.6.10.0100.04020.29
5.6.00.0130.03720.38
5.5.380.0000.04320.32
5.5.370.0030.04320.32
5.5.360.0100.04720.36
5.5.350.0030.08720.39
5.5.340.0070.07020.77
5.5.330.0030.08020.62
5.5.320.0130.04020.78
5.5.310.0000.08320.83
5.5.300.0000.08320.88
5.5.290.0030.08320.75
5.5.280.0030.04720.86
5.5.270.0170.05720.79
5.5.260.0070.08320.74
5.5.250.0070.07720.52
5.5.240.0100.07320.19
5.5.230.0030.07720.15
5.5.220.0070.07720.23
5.5.210.0000.05020.18
5.5.200.0130.04320.23
5.5.190.0070.06320.15
5.5.180.0070.08020.25
5.5.160.0070.04320.19
5.5.150.0130.05319.96
5.5.140.0170.06720.25
5.5.130.0070.04320.21
5.5.120.0130.06320.09
5.5.110.0000.05020.25
5.5.100.0070.05020.16
5.5.90.0070.07320.07
5.5.80.0000.04720.05
5.5.70.0070.03720.04
5.5.60.0030.07719.98
5.5.50.0170.03320.04
5.5.40.0100.03720.11
5.5.30.0030.05319.91
5.5.20.0100.07320.12
5.5.10.0030.04719.95
5.5.00.0000.07020.00
5.4.450.0100.07319.18
5.4.440.0070.07319.45
5.4.430.0100.04019.46
5.4.420.0000.08319.17
5.4.410.0100.08019.09
5.4.400.0100.04319.05
5.4.390.0070.06319.04
5.4.380.0130.07019.10
5.4.370.0000.08019.12
5.4.360.0000.05318.88
5.4.350.0030.05019.23
5.4.340.0100.05018.87
5.4.320.0130.06719.04
5.4.310.0000.05019.18
5.4.300.0070.06319.20
5.4.290.0070.06018.87
5.4.280.0070.07019.14
5.4.270.0100.04019.21
5.4.260.0100.06719.03
5.4.250.0030.07319.18
5.4.240.0170.06319.23
5.4.230.0130.07019.13
5.4.220.0100.07318.98
5.4.210.0070.04018.88
5.4.200.0000.07319.04
5.4.190.0100.07319.13
5.4.180.0100.03319.16
5.4.170.0000.04319.12
5.4.160.0070.06319.12
5.4.150.0170.07019.15
5.4.140.0000.04716.20
5.4.130.0100.07016.18
5.4.120.0070.07016.34
5.4.110.0100.04716.40
5.4.100.0030.08016.57
5.4.90.0030.04016.45
5.4.80.0000.03716.58
5.4.70.0030.06016.48
5.4.60.0070.07316.29
5.4.50.0030.07016.48
5.4.40.0030.06716.50
5.4.30.0030.07016.32
5.4.20.0070.08016.50
5.4.10.0070.07716.45
5.4.00.0000.03315.82
5.3.290.0100.06314.74
5.3.280.0030.05314.65
5.3.270.0070.04014.75
5.3.260.0030.07314.72
5.3.250.0030.04314.64
5.3.240.0030.06014.65
5.3.230.0100.07014.55
5.3.220.0070.08714.54
5.3.210.0070.07714.58
5.3.200.0030.04714.70
5.3.190.0130.05314.56
5.3.180.0000.06314.52
5.3.170.0070.07314.61
5.3.160.0030.07314.61
5.3.150.0070.03014.57
5.3.140.0000.04014.56
5.3.130.0030.06714.63
5.3.120.0070.07714.55
5.3.110.0070.06014.50
5.3.100.0030.03314.05
5.3.90.0070.07714.07
5.3.80.0070.06014.06
5.3.70.0070.06314.14
5.3.60.0070.07314.00
5.3.50.0070.05713.98
5.3.40.0070.05314.07
5.3.30.0030.06714.05
5.3.20.0070.06713.84
5.3.10.0100.06313.61
5.3.00.0070.06713.65
5.2.170.0000.03011.24
5.2.160.0070.05711.24
5.2.150.0030.04311.24
5.2.140.0070.03311.24
5.2.130.0070.05711.24
5.2.120.0030.06311.24
5.2.110.0070.05711.24
5.2.100.0000.03711.24
5.2.90.0000.06311.24
5.2.80.0030.05011.24
5.2.70.0030.06011.24
5.2.60.0030.03711.24
5.2.50.0100.05711.24
5.2.40.0000.04311.24
5.2.30.0000.05711.24
5.2.20.0070.04711.24
5.2.10.0000.05711.24
5.2.00.0030.05011.24
5.1.60.0130.03711.24
5.1.50.0100.04711.24
5.1.40.0030.05311.24
5.1.30.0000.05311.24
5.1.20.0000.04011.24
5.1.10.0000.04711.24
5.1.00.0030.06011.24
5.0.50.0030.04311.24
5.0.40.0070.03711.24
5.0.30.0030.06011.24
5.0.20.0030.04011.24
5.0.10.0030.04311.24
5.0.00.0000.06711.24
4.4.90.0070.01711.24
4.4.80.0070.03011.24
4.4.70.0000.02311.24
4.4.60.0000.03011.24
4.4.50.0000.02011.24
4.4.40.0000.03711.24
4.4.30.0000.02711.24
4.4.20.0000.02311.24
4.4.10.0030.03711.24
4.4.00.0070.05311.24
4.3.110.0030.03311.24
4.3.100.0000.03711.24
4.3.90.0070.03011.24
4.3.80.0030.05011.24
4.3.70.0030.02311.24
4.3.60.0030.01311.24
4.3.50.0000.03711.24
4.3.40.0030.05011.24
4.3.30.0070.03011.24
4.3.20.0000.03711.24
4.3.10.0030.03311.24
4.3.00.0030.03011.24

preferences:
48.57 ms | 401 KiB | 5 Q