3v4l.org

run code in 300+ PHP versions simultaneously
<?php class prototype { private $inherited; private $instance; public function __construct(prototype $prototype = null) { $this->inherited = $prototype; $this->instance = []; } public function __set($name, $value) { if ($value instanceof \Closure) { $value = $value->bindTo($this); } $this->instance[$name] = $value; } public function __get($name) { if (array_key_exists($name, $this->instance)) { return $this->instance[$name]; } else { return $this->inherited->$name; } } public function __call($name, $arguments) { if (!isset($this->instance[$name]) && isset($this->inherited) && ($fromProto = $this->inherited->$name) instanceof \Closure)) { $target = $fromProto->bindTo($this); } else if (isset($this->instance[$name]) && $this->instance[$name] instanceof \Closure) { $target = $this->instance[$name]; } else { return; } return call_user_func_array($target, $arguments); } } $foo = new prototype; $foo->foo = 'Foo!'; $foo->bar = function() { return $this->foo; }; $bar = new prototype($foo); $bar->foo = 'Bar!'; echo $foo->bar() . "\n"; echo $bar->bar() . "\n";

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.200.0100.04112.40
5.4.190.0140.04712.40
5.4.180.0120.04312.40
5.4.170.0110.04012.41
5.4.160.0110.03712.40
5.4.150.0100.04112.40
5.4.140.0070.04112.09
5.4.130.0090.04012.07
5.4.120.0120.05212.04
5.4.110.0070.04412.03
5.4.100.0100.04112.03
5.4.90.0090.04012.03
5.4.80.0080.03912.04
5.4.70.0080.04012.03
5.4.60.0080.03812.03
5.4.50.0120.04012.03
5.4.40.0120.04412.02
5.4.30.0090.03912.01
5.4.20.0110.04012.01
5.4.10.0110.04312.01
5.4.00.0130.04611.51
5.3.270.0090.04212.73
5.3.260.0100.04112.72
5.3.250.0150.04712.72
5.3.240.0090.04912.72
5.3.230.0100.04712.71
5.3.220.0110.04212.68
5.3.210.0100.04212.68
5.3.200.0120.03912.68
5.3.190.0130.04712.68
5.3.180.0170.06312.67
5.3.170.0160.05112.67
5.3.160.0120.04712.67
5.3.150.0150.04312.67
5.3.140.0120.04312.66
5.3.130.0120.04812.66
5.3.120.0120.03912.66
5.3.110.0070.04412.66
5.3.100.0100.04012.12
5.3.90.0090.03912.10
5.3.80.0120.04112.08
5.3.70.0090.04212.09
5.3.60.0110.03912.08
5.3.50.0110.03812.02
5.3.40.0140.05412.02
5.3.30.0090.03811.98
5.3.20.0120.03711.76
5.3.10.0100.03811.73
5.3.00.0090.04011.71

preferences:
137.53 ms | 1394 KiB | 7 Q