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(){ $this->secret = rot_13($this->secret); }; $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.40.0140.00018.91
8.3.30.0070.00719.23
8.3.20.0030.00620.20
8.3.10.0080.00022.05
8.3.00.0000.00822.52
8.2.170.0070.01422.96
8.2.160.0150.00020.44
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0000.00919.35
8.2.110.0030.00622.11
8.2.100.0070.00319.39
8.2.90.0030.00519.26
8.2.80.0030.00617.97
8.2.70.0000.00917.63
8.2.60.0060.00317.93
8.2.50.0050.00518.07
8.2.40.0050.00318.22
8.2.30.0080.00018.19
8.2.20.0040.00417.85
8.2.10.0000.00817.74
8.2.00.0040.00417.82
8.1.270.0040.01122.24
8.1.260.0090.00026.35
8.1.250.0090.00028.09
8.1.240.0030.00723.83
8.1.230.0070.00419.14
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0000.00917.35
8.1.190.0040.00417.53
8.1.180.0060.00318.10
8.1.170.0040.00418.63
8.1.160.0000.00822.08
8.1.150.0040.00418.69
8.1.140.0040.00417.45
8.1.130.0000.00717.78
8.1.120.0040.00417.41
8.1.110.0040.00417.45
8.1.100.0000.00717.46
8.1.90.0040.00417.40
8.1.80.0000.00717.54
8.1.70.0000.00717.43
8.1.60.0060.00317.57
8.1.50.0000.00717.61
8.1.40.0030.00617.44
8.1.30.0050.00217.61
8.1.20.0030.00517.60
8.1.10.0000.00717.66
8.1.00.0030.00617.55
8.0.300.0040.00418.77
8.0.290.0000.00717.05
8.0.280.0050.00318.32
8.0.270.0070.00017.28
8.0.260.0000.00716.84
8.0.250.0030.00317.07
8.0.240.0050.00316.91
8.0.230.0050.00317.02
8.0.220.0030.00316.83
8.0.210.0030.00316.96
8.0.200.0060.00316.94
8.0.190.0000.00717.07
8.0.180.0050.00216.88
8.0.170.0040.00417.02
8.0.160.0040.00416.84
8.0.150.0000.00716.87
8.0.140.0040.00416.93
8.0.130.0030.00313.34
8.0.120.0000.00816.84
8.0.110.0040.00416.83
8.0.100.0040.00416.87
8.0.90.0080.00016.91
8.0.80.0050.01217.00
8.0.70.0040.00416.99
8.0.60.0040.00416.82
8.0.50.0000.00716.91
8.0.30.0100.01017.10
8.0.20.0140.00817.40
8.0.10.0000.00717.02
8.0.00.0140.00716.80
7.4.330.0000.00615.09
7.4.320.0000.00616.52
7.4.300.0030.00316.52
7.4.290.0070.00016.41
7.4.280.0070.00016.38
7.4.270.0080.00016.63
7.4.260.0070.00016.41
7.4.250.0040.00416.41
7.4.240.0040.00316.52
7.4.230.0040.00416.36
7.4.220.0070.01016.66
7.4.210.0080.00616.55
7.4.200.0050.00316.72
7.4.190.0000.00816.48
7.4.160.0110.00616.68
7.4.150.0070.01017.40
7.4.140.0090.01417.86
7.4.130.0080.01016.46
7.4.120.0080.01016.63
7.4.110.0100.01416.38
7.4.100.0130.01016.57
7.4.90.0030.01316.49
7.4.80.0070.01119.39
7.4.70.0110.00516.63
7.4.60.0090.01416.68
7.4.50.0030.00616.63
7.4.40.0070.01122.77
7.4.30.0070.01016.52
7.4.00.0080.00915.14
7.3.330.0000.00613.32
7.3.320.0030.00313.45
7.3.310.0000.00716.55
7.3.300.0030.00316.45
7.3.290.0130.00316.42
7.3.280.0060.01016.46
7.3.270.0070.01017.40
7.3.260.0140.00316.45
7.3.250.0110.00616.43
7.3.240.0110.01116.52
7.3.230.0150.00316.55
7.3.210.0130.00316.52
7.3.200.0080.00319.39
7.3.190.0100.01216.54
7.3.180.0070.01016.41
7.3.170.0060.01016.58
7.3.160.0130.00316.65
7.3.120.0060.01114.87
7.3.110.0060.01214.82
7.3.100.0170.00015.06
7.3.90.0090.00915.03
7.3.80.0060.00615.08
7.3.70.0040.01114.97
7.3.60.0090.00314.55
7.3.50.0090.00614.79
7.3.40.0090.00614.70
7.3.30.0030.01314.94
7.3.20.0000.01016.79
7.3.10.0100.00316.80
7.3.00.0070.00716.73
7.2.330.0160.00216.60
7.2.320.0070.01116.56
7.2.310.0140.00816.79
7.2.300.0130.00716.66
7.2.290.0090.01216.68
7.2.250.0060.00914.74
7.2.240.0130.00614.68
7.2.230.0060.00915.28
7.2.220.0060.00715.02
7.2.210.0070.00315.37
7.2.200.0080.00415.18
7.2.190.0110.00315.03
7.2.180.0000.01514.91
7.2.170.0000.01615.18
7.2.130.0040.00816.70
7.2.120.0040.01116.98
7.2.110.0040.00416.94
7.2.100.0000.00916.92
7.2.90.0070.00717.00
7.2.80.0070.00416.93
7.2.70.0040.00716.93
7.2.60.0080.00817.02
7.2.50.0040.01216.64
7.2.40.0000.01817.03
7.2.30.0030.01016.95
7.2.20.0080.00417.00
7.2.10.0060.00916.89
7.2.00.0060.00618.18
7.1.330.0110.00615.89
7.1.320.0040.01115.65
7.1.310.0000.01615.77
7.1.300.0100.00715.88
7.1.290.0000.01215.98
7.1.280.0040.01215.84
7.1.270.0110.00415.79
7.1.260.0040.00815.45
7.1.250.0070.00715.70
7.1.240.0030.00515.89
7.1.230.0030.00615.94
7.1.220.0040.00415.75
7.1.210.0030.01315.50
7.1.200.0020.00815.79
7.1.190.0090.00615.96
7.1.180.0100.00315.95
7.1.170.0070.00315.60
7.1.160.0030.01115.80
7.1.150.0040.01115.77
7.1.140.0030.00915.97
7.1.130.0000.01315.98
7.1.120.0030.01015.95
7.1.110.0070.00715.90
7.1.100.0030.00816.97
7.1.90.0030.00615.85
7.1.80.0080.00815.79
7.1.70.0060.00516.33
7.1.60.0050.01317.78
7.1.50.0070.01216.40
7.1.40.0070.00715.84
7.1.30.0060.00315.75
7.1.20.0070.01015.93
7.1.10.0000.01415.53
7.1.00.0020.04319.04
7.0.330.0030.00615.20
7.0.320.0000.01415.42
7.0.310.0040.00415.49
7.0.300.0090.00615.43
7.0.290.0040.01115.53
7.0.280.0100.00015.55
7.0.270.0060.00615.34
7.0.260.0030.01015.56
7.0.250.0040.01115.24
7.0.240.0090.00615.23
7.0.230.0030.00715.48
7.0.220.0030.00515.48
7.0.210.0030.00915.45
7.0.200.0020.00716.04
7.0.190.0070.00315.29
7.0.180.0030.01015.43
7.0.170.0070.00315.63
7.0.160.0030.00815.45
7.0.150.0040.01115.37
7.0.140.0020.04318.87
7.0.130.0030.00615.41
7.0.120.0030.01315.43
7.0.110.0060.00315.35
7.0.100.0050.00515.52
7.0.90.0070.00715.48
7.0.80.0070.00715.37
7.0.70.0000.01115.22
7.0.60.0040.03117.74
7.0.50.0080.04016.68
7.0.40.0060.02616.74
7.0.30.0290.02516.81
7.0.20.0150.02916.78
7.0.10.0030.04216.77
7.0.00.0070.04616.81
5.6.380.0120.00414.36
5.6.370.0030.00914.29
5.6.360.0130.00314.21
5.6.350.0080.00014.51
5.6.340.0040.00414.57
5.6.330.0110.00614.64
5.6.320.0060.00614.11
5.6.310.0080.00314.43
5.6.300.0030.00714.28
5.6.290.0100.00314.31
5.6.280.0070.03917.70
5.6.270.0000.01314.46
5.6.260.0030.00914.46
5.6.250.0040.00414.21
5.6.240.0090.00014.12
5.6.230.0090.00614.63
5.6.220.0110.00014.32
5.6.210.0030.02317.41
5.6.200.0070.02216.33
5.6.190.0100.02317.38
5.6.180.0220.03817.49
5.6.170.0150.03217.43
5.6.160.0070.02817.48
5.6.150.0080.03816.44
5.6.140.0100.04016.29
5.6.130.0070.04716.40
5.6.120.0080.02617.79
5.6.110.0070.04017.80
5.6.100.0060.04017.71
5.6.90.0080.04017.76
5.6.80.0080.03717.26
5.6.70.0030.02617.24
5.6.60.0030.00714.42
5.6.50.0070.00314.20
5.6.40.0050.00514.26
5.6.30.0000.00714.35
5.6.20.0060.00314.24
5.6.10.0000.00914.23
5.6.00.0000.01114.34
5.5.380.0030.00711.18
5.5.370.0050.00211.18
5.5.360.0070.00311.18
5.5.350.0070.04415.88
5.5.340.0050.04414.57
5.5.330.0020.04815.75
5.5.320.0140.02715.85
5.5.310.0100.02315.80
5.5.300.0110.01814.65
5.5.290.0060.04014.74
5.5.280.0030.02516.01
5.5.270.0110.04016.02
5.5.260.0050.03316.09
5.5.250.0070.03715.95
5.5.240.0090.03615.70
5.5.230.0060.00311.23
5.5.220.0040.00411.23
5.5.210.0040.00411.18
5.5.200.0070.00411.18
5.5.190.0100.00011.19
5.5.180.0000.01111.19
5.5.170.0040.00411.36
5.5.160.0000.01111.18
5.5.150.0120.00011.44
5.5.140.0000.00611.39
5.5.130.0030.00611.29
5.5.120.0030.00611.38
5.5.110.0060.00611.18
5.5.100.0050.00011.19
5.5.90.0040.00411.18
5.5.80.0050.00311.18
5.5.70.0030.00611.18
5.5.60.0080.00011.18
5.5.50.0040.00411.18
5.5.40.0000.01311.18
5.5.30.0080.00311.18
5.5.20.0070.00311.18
5.5.10.0060.00611.18
5.5.00.0000.00911.18
5.4.450.0370.03715.28
5.4.440.0380.03315.40
5.4.430.0070.03015.19
5.4.420.0120.02715.37
5.4.410.0020.03715.14
5.4.400.0400.00315.02
5.4.390.0420.00314.89
5.4.380.0170.03214.84
5.4.370.0180.02714.83
5.4.360.0180.02014.86
5.4.350.0130.03314.94
5.4.340.0170.02714.95
5.4.330.0090.00311.31
5.4.320.0060.02111.85
5.4.310.0100.02211.84
5.4.300.0070.02311.85
5.4.290.0070.02411.84
5.4.280.0030.02611.79
5.4.270.0080.02815.02
5.4.260.0030.03315.10
5.4.250.0030.03515.13
5.4.240.0070.03815.01
5.4.230.0050.04014.97
5.4.220.0070.04615.13
5.4.210.0090.03915.05
5.4.200.0130.02515.13
5.4.190.0060.03315.03
5.4.180.0070.03214.96
5.4.170.0130.02515.06
5.4.160.0050.04015.08
5.4.150.0060.03314.91
5.4.140.0080.02713.83
5.4.130.0070.02413.81
5.4.120.0130.03013.92
5.4.110.0080.02813.81
5.4.100.0070.03813.85
5.4.90.0100.03313.86
5.4.80.0150.02613.80
5.4.70.0020.04013.91
5.4.60.0090.02513.82
5.4.50.0060.02613.81
5.4.40.0050.03613.79
5.4.30.0050.03613.82
5.4.20.0100.02313.79
5.4.10.0130.03113.74
5.4.00.0110.02613.59
5.3.290.0060.02211.99
5.3.280.0020.03612.94
5.3.270.0050.04012.95
5.3.260.0060.04012.89
5.3.250.0030.03412.94
5.3.240.0090.03512.98
5.3.230.0020.03012.94
5.3.220.0060.03812.98
5.3.210.0050.03312.88
5.3.200.0070.03912.88
5.3.190.0020.04012.95
5.3.180.0030.03012.87
5.3.170.0050.03312.79
5.3.160.0050.02712.92
5.3.150.0030.03712.88
5.3.140.0080.02812.93
5.3.130.0090.03312.86
5.3.120.0080.03912.86
5.3.110.0070.02712.91
5.3.100.0100.02312.71
5.3.90.0070.03512.56
5.3.80.0100.02512.69
5.3.70.0070.03212.70
5.3.60.0070.02312.65
5.3.50.0070.02812.57
5.3.40.0070.03312.59
5.3.30.0030.03312.63
5.3.20.0070.02912.48
5.3.10.0110.02012.46
5.3.00.0080.02612.40
5.2.170.0060.02511.14
5.2.160.0100.01811.20
5.2.150.0080.02211.14
5.2.140.0030.03311.08
5.2.130.0060.02011.14
5.2.120.0070.02311.14
5.2.110.0050.02111.13
5.2.100.0030.03011.19
5.2.90.0050.03311.22
5.2.80.0030.02411.17
5.2.70.0070.02611.13
5.2.60.0040.02311.23
5.2.50.0070.02711.14
5.2.40.0050.02711.13
5.2.30.0070.02911.16
5.2.20.0030.02311.16
5.2.10.0050.02111.06
5.2.00.0080.02110.95
5.1.60.0030.02210.59
5.1.50.0050.02410.58
5.1.40.0000.02110.62
5.1.30.0050.02010.80
5.1.20.0080.02510.69
5.1.10.0030.02410.72
5.1.00.0030.02710.75
5.0.50.0050.0169.96
5.0.40.0030.0219.88
5.0.30.0030.0219.74
5.0.20.0030.0209.74
5.0.10.0020.0189.70
5.0.00.0020.0279.68
4.4.90.0020.0138.90
4.4.80.0030.0128.90
4.4.70.0070.0108.90
4.4.60.0070.0108.90
4.4.50.0020.0168.90
4.4.40.0000.0208.90
4.4.30.0050.0108.90
4.4.20.0030.0158.90
4.4.10.0040.0158.90
4.4.00.0020.0198.90
4.3.110.0020.0148.90
4.3.100.0020.0148.90
4.3.90.0030.0128.90
4.3.80.0080.0128.90
4.3.70.0000.0148.90
4.3.60.0020.0128.90
4.3.50.0020.0158.90
4.3.40.0030.0188.90
4.3.30.0030.0138.90
4.3.20.0030.0118.90
4.3.10.0030.0118.90
4.3.00.0050.0148.80

preferences:
42.95 ms | 400 KiB | 5 Q