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 something that became available in 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 $testArr = (array) $test; $secret = array_shift($testArr); echo 'xxx '.$secret.' xxx'; class Obj implements ArrayAccess { private $t; public function __construct($t) { $this->t = $t; return; } public function offsetSet($offset, $value) { return; } public function offsetExists($offset) { return; } public function offsetUnset($offset) { return; } public function offsetGet($offset) { return 'callback'; } public function __invoke() { $tObj = $this->t; return function(&$tObj) { print_r($t); }; } } $obj = new Obj($test); $test->x = $obj; // 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.0180.00916.50
8.3.50.0110.00316.34
8.3.40.0090.00618.70
8.3.30.0110.00418.82
8.3.20.0050.00320.34
8.3.10.0040.00421.04
8.3.00.0070.00020.20
8.2.180.0120.00318.61
8.2.170.0110.00722.96
8.2.160.0110.00321.17
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0070.00019.32
8.2.120.0030.00626.35
8.2.110.0030.00722.20
8.2.100.0120.00017.99
8.2.90.0080.00419.34
8.2.80.0030.00617.97
8.2.70.0040.00417.75
8.2.60.0040.00417.93
8.2.50.0040.00418.10
8.2.40.0040.00420.35
8.2.30.0040.00419.32
8.2.20.0050.00218.02
8.2.10.0040.00418.15
8.2.00.0000.00718.12
8.1.280.0070.01425.92
8.1.270.0050.00321.93
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0060.00323.98
8.1.230.0060.00620.20
8.1.220.0090.00017.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0080.00018.55
8.1.160.0070.00018.84
8.1.150.0030.00522.05
8.1.140.0050.00219.61
8.1.130.0040.00417.48
8.1.120.0000.00717.56
8.1.110.0030.00517.38
8.1.100.0040.00417.44
8.1.90.0030.00617.39
8.1.80.0040.00417.53
8.1.70.0030.00317.46
8.1.60.0030.00517.64
8.1.50.0000.00717.57
8.1.40.0000.00717.42
8.1.30.0060.00317.58
8.1.20.0000.00817.60
8.1.10.0040.00417.60
8.1.00.0040.00417.52
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0030.00518.39
8.0.270.0060.00317.29
8.0.260.0080.00016.98
8.0.250.0000.00717.09
8.0.240.0060.00317.05
8.0.230.0050.00516.95
8.0.220.0000.00816.87
8.0.210.0030.00316.98
8.0.200.0040.00417.04
8.0.190.0070.00017.08
8.0.180.0040.00417.00
8.0.170.0080.00016.98
8.0.160.0050.00317.01
8.0.150.0040.00416.88
8.0.140.0030.00316.84
8.0.130.0000.00613.48
8.0.120.0040.00416.89
8.0.110.0000.00716.85
8.0.100.0040.00416.96
8.0.90.0050.00316.82
8.0.80.0070.01017.01
8.0.70.0080.00016.84
8.0.60.0000.00817.05
8.0.50.0000.00717.05
8.0.30.0080.00917.20
8.0.20.0100.01017.40
8.0.10.0040.00416.99
8.0.00.0070.01017.00
7.4.330.0050.00015.55
7.4.320.0000.00616.54
7.4.300.0060.00016.65
7.4.290.0040.00416.55
7.4.280.0070.00016.62
7.4.270.0000.00716.49
7.4.260.0030.00316.52
7.4.250.0030.00316.40
7.4.240.0070.00016.63
7.4.230.0000.00716.51
7.4.220.0100.01016.50
7.4.210.0040.01716.45
7.4.200.0070.00016.42
7.4.160.0100.00916.67
7.4.150.0090.00917.40
7.4.140.0100.00817.86
7.4.130.0030.01816.53
7.4.120.0100.00816.49
7.4.110.0140.00516.54
7.4.100.0120.00616.52
7.4.90.0090.00916.63
7.4.80.0100.00719.39
7.4.70.0130.00316.54
7.4.60.0070.01116.56
7.4.50.0070.01016.62
7.4.40.0100.01316.37
7.4.30.0150.00316.61
7.4.00.0070.00914.91
7.3.330.0030.00313.20
7.3.320.0030.00313.35
7.3.310.0040.00416.53
7.3.300.0000.00716.45
7.3.290.0090.00616.37
7.3.280.0080.01016.45
7.3.270.0070.01117.40
7.3.260.0150.00316.53
7.3.250.0100.00716.49
7.3.240.0090.00816.55
7.3.230.0100.00716.53
7.3.210.0000.01716.32
7.3.200.0110.00516.46
7.3.190.0070.01316.45
7.3.180.0070.01016.36
7.3.170.0090.00616.54
7.3.160.0080.00916.38
7.3.120.0070.01114.96
7.3.110.0060.00814.94
7.3.100.0090.00614.78
7.3.90.0080.00514.78
7.3.80.0060.00614.98
7.3.70.0040.01114.88
7.3.60.0050.00714.99
7.3.50.0050.01114.94
7.3.40.0020.01114.67
7.3.30.0090.00314.90
7.3.20.0060.00616.73
7.3.10.0040.00816.78
7.3.00.0070.00516.76
7.2.330.0060.01216.75
7.2.320.0090.01216.48
7.2.310.0060.01316.82
7.2.300.0100.00716.84
7.2.290.0100.00716.54
7.2.250.0000.01915.02
7.2.240.0080.00914.92
7.2.230.0050.00915.08
7.2.220.0080.00615.16
7.2.210.0080.00915.17
7.2.200.0080.00815.03
7.2.190.0030.01015.15
7.2.180.0050.01015.22
7.2.170.0090.00415.22
7.2.160.0040.00814.97
7.2.150.0060.01016.90
7.2.140.0030.00916.89
7.2.130.0070.01016.75
7.2.120.0110.00016.94
7.2.110.0070.01116.70
7.2.100.0060.01117.10
7.2.90.0030.00717.16
7.2.80.0120.00417.18
7.2.70.0070.00416.83
7.2.60.0040.00516.96
7.2.50.0030.01416.99
7.2.40.0030.00616.86
7.2.30.0090.00616.90
7.2.20.0070.00717.07
7.2.10.0040.01116.84
7.2.00.0060.01017.05
7.1.330.0020.01315.72
7.1.320.0020.01215.77
7.1.310.0030.01016.06
7.1.300.0030.00815.81
7.1.290.0070.00715.93
7.1.280.0050.00715.55
7.1.270.0020.01115.77
7.1.260.0080.00515.72
7.1.250.0100.00315.86
7.1.200.0040.00815.73
7.1.90.0050.01118.07
7.1.80.0030.01018.32
7.1.70.0060.00617.08
7.1.60.0160.01034.80
7.1.50.0100.01734.74
7.1.40.0200.00834.27
7.1.30.0220.01534.52
7.1.20.0180.00934.61
7.1.10.0000.01316.46
7.1.00.0050.00816.69
7.0.200.0040.00916.79
7.0.190.0030.01016.67
7.0.180.0030.01016.32
7.0.170.0000.01316.18
7.0.160.0000.01316.49
7.0.150.0030.01016.34
7.0.140.0100.00316.43
7.0.130.0060.00616.43
7.0.120.0060.00916.58
7.0.110.0120.00616.33
7.0.100.0090.00616.23
7.0.90.0050.00716.19
7.0.80.0060.00916.37
7.0.70.0060.01116.27
7.0.60.0040.01116.01
7.0.50.0030.01016.34
7.0.40.0030.01016.55
7.0.30.0030.01016.52
7.0.20.0030.00916.32
7.0.10.0080.00816.18
7.0.00.0040.00916.32

preferences:
59.64 ms | 400 KiB | 5 Q