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 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 A implements ArrayAccess { private $callCount = 0; public function __invoke(){ $host = $this; return function() use ($host){ $this->secret = "HELLO WORLD"; } } public function offsetSet($offset, $value) {} public function offsetExists($offset) { return true; } public function offsetUnset($offset) {} public function offsetGet($offset) { $this->callCount++; if ($this->callCount == 1){ $r = $this; } else { $r = "FOO"; } return $r; } } $test->foo = new A; // 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)
5.4.250.0130.06018.95
5.4.240.0270.04718.83
5.4.230.0130.05718.91
5.4.220.0100.08018.96
5.4.210.0070.06318.74
5.4.200.0130.05318.75
5.4.190.0070.06018.75
5.4.180.0100.05318.98
5.4.170.0100.05319.01
5.4.160.0100.06318.95
5.4.150.0200.06719.00
5.4.140.0100.05016.40
5.4.130.0130.04316.42
5.4.120.0170.04716.40
5.4.110.0200.04716.38
5.4.100.0130.06016.52
5.4.90.0100.04716.66
5.4.80.0170.05716.32
5.4.70.0100.07016.43
5.4.60.0170.06016.43
5.4.50.0100.05016.43
5.4.40.0100.05016.56
5.4.30.0200.05316.34
5.4.20.0100.05716.34
5.4.10.0170.06316.45
5.4.00.0170.04315.92
5.3.280.0000.07314.58
5.3.270.0200.05314.84
5.3.260.0030.06314.60
5.3.250.0100.05314.75
5.3.240.0100.05714.70
5.3.230.0230.04014.63
5.3.220.0030.05314.64
5.3.210.0130.05314.55
5.3.200.0070.06714.66
5.3.190.0070.06314.72
5.3.180.0030.05714.41
5.3.170.0130.07314.56
5.3.160.0130.06714.81
5.3.150.0200.04314.80
5.3.140.0100.05014.65
5.3.130.0200.06014.74
5.3.120.0130.05014.66
5.3.110.0000.06314.55
5.3.100.0100.05314.14
5.3.90.0030.06014.02
5.3.80.0130.04314.12
5.3.70.0100.07014.11
5.3.60.0030.05714.07
5.3.50.0170.06014.14
5.3.40.0100.05714.05
5.3.30.0100.06713.94
5.3.20.0200.05713.73
5.3.10.0100.06713.82
5.3.00.0130.04313.56

preferences:
141.45 ms | 1386 KiB | 7 Q