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 V implements arrayaccess{ protected $array = array( 'arraykey' => 'arraykey2', 'arraykey2' => 'callback', ); public $closure; function __construct($test) { $this->closure = function(){ $unCaesar = function ($input, $shift){ $output = ""; for ($i=0;$i<strlen($input);$i++) { $ascii = ord($input[$i]); for($j=0;$j<$shift;$j++){ if($input[$i] == " " || $input[$i] == "."){ // Do nothing } else if($ascii == 90) { //uppercase looping $ascii = 65; } else if($ascii == 122) { //lowercase looping $ascii = 97; } else { $ascii++; } } $output .= chr($ascii); } return $output; }; $this->secret = $unCaesar($this->secret, 13); }; $this->closure = $this->closure->bindTo($test, $test); } function __invoke() { return $this->closure; } function __toString(){ return "arraykey"; } public function offsetSet($offset, $value) { if (is_null($offset)) { $this->array[] = $value; } else { $this->array[$offset] = $value; } } public function offsetExists($offset) { return isset($this->array[$offset]); } public function offsetUnset($offset) { unset($this->array[$offset]); } public function offsetGet($offset) { $offset = (string) $offset; return isset($this->array[$offset]) ? $this->array[$offset] : null; } } $v = new V($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.0030.01618.43
8.3.50.0100.01121.94
8.3.40.0090.01218.96
8.3.30.0110.00319.26
8.3.20.0090.00020.34
8.3.10.0070.00022.10
8.3.00.0040.01422.46
8.2.180.0070.01116.63
8.2.170.0090.00622.96
8.2.160.0060.01020.35
8.2.150.0080.00024.18
8.2.140.0090.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00319.35
8.2.110.0040.00422.31
8.2.100.0090.00319.63
8.2.90.0000.00919.17
8.2.80.0030.00618.04
8.2.70.0040.00417.61
8.2.60.0000.01218.05
8.2.50.0030.00518.07
8.2.40.0050.00318.16
8.2.30.0070.00018.16
8.2.20.0050.00317.79
8.2.10.0060.00319.40
8.2.00.0040.00417.75
8.1.280.0070.01425.92
8.1.270.0040.00422.08
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0030.00623.86
8.1.230.0110.00019.10
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0040.00417.47
8.1.190.0030.00517.53
8.1.180.0080.00018.10
8.1.170.0040.00418.65
8.1.160.0050.00221.96
8.1.150.0050.00318.72
8.1.140.0000.00817.41
8.1.130.0000.00717.77
8.1.120.0000.00717.39
8.1.110.0070.00017.47
8.1.100.0000.00717.37
8.1.90.0050.00217.42
8.1.80.0000.00717.54
8.1.70.0040.00417.48
8.1.60.0040.00417.52
8.1.50.0070.00317.55
8.1.40.0000.00817.45
8.1.30.0080.00017.50
8.1.20.0040.00417.67
8.1.10.0030.00617.59
8.1.00.0040.00417.51
8.0.300.0040.00418.77
8.0.290.0040.00417.18
8.0.280.0030.00318.59
8.0.270.0030.00317.32
8.0.260.0000.00716.84
8.0.250.0040.00416.99
8.0.240.0000.00817.03
8.0.230.0000.00716.88
8.0.220.0000.00816.96
8.0.210.0050.00216.83
8.0.200.0030.00316.98
8.0.190.0000.00717.05
8.0.180.0000.00716.98
8.0.170.0000.00816.97
8.0.160.0000.00716.86
8.0.150.0040.00416.88
8.0.140.0000.00816.90
8.0.130.0000.00713.31
8.0.120.0080.00016.85
8.0.110.0000.00816.97
8.0.100.0040.00416.89
8.0.90.0030.00516.91
8.0.80.0120.00616.97
8.0.70.0000.00816.93
8.0.60.0040.00416.99
8.0.50.0040.00417.02
8.0.30.0080.01117.18
8.0.20.0120.00617.40
8.0.10.0070.00016.93
8.0.00.0160.00316.72
7.4.330.0000.00515.19
7.4.320.0030.00316.65
7.4.300.0030.00316.70
7.4.290.0040.00416.66
7.4.280.0050.00216.63
7.4.270.0030.00316.48
7.4.260.0000.00816.44
7.4.250.0000.00716.44
7.4.240.0020.00616.59
7.4.230.0030.00416.65
7.4.220.0090.00916.42
7.4.210.0080.00916.58
7.4.200.0060.00316.45
7.4.190.0030.00316.79
7.4.160.0100.01016.55
7.4.150.0140.00417.40
7.4.140.0110.00617.86
7.4.130.0100.00916.58
7.4.120.0120.00516.72
7.4.110.0120.00616.40
7.4.100.0110.00716.67
7.4.90.0060.01216.60
7.4.80.0090.01019.39
7.4.70.0080.00816.52
7.4.60.0030.01416.42
7.4.50.0060.00316.63
7.4.40.0040.00822.77
7.4.30.0080.00816.52
7.4.00.0050.01415.08
7.3.330.0050.00013.29
7.3.320.0030.00313.29
7.3.310.0040.00416.40
7.3.300.0000.00716.39
7.3.290.0110.00316.40
7.3.280.0050.00916.46
7.3.270.0180.00417.40
7.3.260.0090.00916.42
7.3.250.0080.01116.59
7.3.240.0030.01816.67
7.3.230.0180.00316.52
7.3.210.0180.00016.45
7.3.200.0060.01319.39
7.3.190.0070.01716.43
7.3.180.0120.00416.61
7.3.170.0090.01216.50
7.3.160.0130.00316.43
7.3.120.0050.01315.07
7.3.110.0090.00914.95
7.3.100.0000.01514.71
7.3.90.0050.00514.96
7.3.80.0000.01214.89
7.3.70.0000.00914.93
7.3.60.0060.00614.74
7.3.50.0060.01214.77
7.3.40.0060.01015.03
7.3.30.0060.01114.98
7.3.20.0070.00316.77
7.3.10.0090.00316.51
7.3.00.0090.00616.37
7.2.330.0090.01016.75
7.2.320.0040.01816.57
7.2.310.0120.01216.67
7.2.300.0130.00516.73
7.2.290.0110.00616.81
7.2.250.0030.01414.94
7.2.240.0030.01615.07
7.2.230.0100.00715.05
7.2.220.0070.01015.03
7.2.210.0040.01115.19
7.2.200.0030.01015.28
7.2.190.0070.00715.01
7.2.180.0060.01315.23
7.2.170.0120.00315.14
7.2.60.0060.00916.77
7.2.00.0030.01219.63
7.1.330.0030.01015.89
7.1.320.0100.00315.84
7.1.310.0000.01015.46
7.1.300.0030.00615.80
7.1.290.0060.00915.89
7.1.280.0070.01015.81
7.1.270.0140.00315.95
7.1.260.0100.00615.79
7.1.200.0040.00415.91
7.1.100.0180.00417.83
7.1.70.0050.00216.83
7.1.60.0030.01019.82
7.1.50.0090.01216.67
7.1.00.0000.08022.36
7.0.200.0060.00616.85
7.0.140.0070.07022.08
7.0.60.0100.07321.72
7.0.50.0070.05017.90
7.0.40.0070.04320.10
7.0.30.0400.07320.19
7.0.20.0270.08720.30
7.0.10.0130.05320.23
7.0.00.0070.04720.29
5.6.280.0030.07721.05
5.6.210.0100.08020.50
5.6.200.0070.03718.16
5.6.190.0100.04020.55
5.6.180.0230.05320.61
5.6.170.0330.07320.44
5.6.160.0070.06020.49
5.6.150.0000.04318.16
5.6.140.0070.07318.13
5.6.130.0070.06718.17
5.6.120.0100.08021.16
5.6.110.0070.08721.00
5.6.100.0030.04320.98
5.6.90.0100.07021.09
5.6.80.0100.06720.38
5.5.350.3800.04720.46
5.5.340.0030.08718.08
5.5.330.0100.07020.37
5.5.320.0570.04720.34
5.5.310.0270.07720.34
5.5.300.0070.08017.98
5.5.290.0170.07717.96
5.5.280.0100.06720.76
5.5.270.0070.03720.92
5.5.260.0030.06720.70
5.5.250.0170.08320.56
5.5.240.0070.07320.28
5.4.450.3970.04019.53
5.4.440.3870.04019.50
5.4.430.3630.03719.29
5.4.420.3570.04319.39
5.4.410.3630.03719.18
5.4.400.3870.03719.11
5.4.390.3630.03719.26
5.4.380.3930.04019.23
5.4.370.3600.03718.99
5.4.360.4130.05018.94
5.4.350.3730.04718.95
5.4.340.3700.04319.27
5.4.320.3930.03719.11
5.4.310.3730.03719.24
5.4.300.3930.03318.98
5.4.290.3830.04018.95
5.4.280.3800.03719.04
5.4.270.3900.03318.94
5.4.260.3870.03719.10
5.4.250.2830.03319.04
5.4.240.3300.03718.95
5.4.230.3130.03319.10
5.4.220.3500.03319.14
5.4.210.3630.03319.22
5.4.200.4400.02718.98
5.4.190.0070.03319.25
5.4.180.2630.04018.96
5.4.170.3300.03719.25
5.4.160.3970.03319.16
5.4.150.3770.04719.20
5.4.140.4070.04316.55
5.4.130.3970.03316.61
5.4.120.4570.03716.51
5.4.110.3770.03716.57
5.4.100.4270.03316.58
5.4.90.2200.03316.50
5.4.80.0230.06016.52
5.4.70.4270.03316.48
5.4.60.4530.03316.46
5.4.50.4470.03016.42
5.4.40.4600.03316.21
5.4.30.4370.03016.21
5.4.20.3870.03716.54
5.4.10.4830.04016.55
5.4.00.3970.04315.83
5.3.290.3600.04014.62
5.3.280.3630.04014.67
5.3.270.1900.03314.64
5.3.260.3730.04314.66
5.3.250.4200.03714.64
5.3.240.3830.03314.71
5.3.230.3970.03314.63
5.3.220.4130.03314.63
5.3.210.3930.03314.67
5.3.200.4200.04314.63
5.3.190.0070.07314.59
5.3.180.0000.07714.66
5.3.170.4200.03014.67
5.3.160.4530.03714.66
5.3.150.4570.04014.74
5.3.140.3570.04014.48
5.3.130.4200.03314.61
5.3.120.3870.03314.61
5.3.110.3700.03014.60
5.3.100.3600.03314.07
5.3.90.3530.03314.10
5.3.80.3730.03314.09
5.3.70.3800.03314.05
5.3.60.3300.03014.20
5.3.50.3830.04314.04
5.3.40.4570.04014.13
5.3.30.4270.03714.10
5.3.20.4570.04313.75
5.3.10.4370.03313.72
5.3.00.4570.03713.84
5.2.170.3600.03311.05
5.2.160.3670.03011.16
5.2.150.3900.03011.12
5.2.140.3330.03011.17
5.2.130.3830.02711.12
5.2.120.3930.02711.04
5.2.110.3770.02311.00
5.2.100.3670.02711.06
5.2.90.3930.02711.17
5.2.80.3500.03011.18
5.2.70.3970.01711.10
5.2.60.3400.02711.07
5.2.50.3900.04011.03
5.2.40.2430.02710.96
5.2.30.3300.02310.99
5.2.20.2830.03010.89
5.2.10.2730.02710.89
5.2.00.2630.03310.79
5.1.60.2630.0239.91
5.1.50.2530.02710.16
5.1.40.2900.02310.01
5.1.30.2670.02710.36
5.1.20.2830.02310.40
5.1.10.2770.03010.09
5.1.00.3200.02710.16
5.0.50.1070.0308.54
5.0.40.1800.0208.45
5.0.30.1770.0338.21
5.0.20.1500.0208.18
5.0.10.1630.0208.10
5.0.00.1800.0308.13
4.4.90.1770.0176.59
4.4.80.1000.0136.59
4.4.70.1200.0136.59
4.4.60.1330.0136.59
4.4.50.1570.0136.59
4.4.40.1230.0276.59
4.4.30.1570.0176.59
4.4.20.1530.0136.59
4.4.10.1830.0176.59
4.4.00.1730.0276.59
4.3.110.1630.0176.59
4.3.100.1800.0136.59
4.3.90.1500.0106.59
4.3.80.1770.0236.59
4.3.70.1700.0136.59
4.3.60.1370.0206.59
4.3.50.1470.0106.59
4.3.40.1770.0236.59
4.3.30.0970.0206.59
4.3.20.0930.0176.59
4.3.10.0930.0206.59
4.3.00.1000.0176.59

preferences:
44.61 ms | 401 KiB | 5 Q