3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Magic { private $propertyMap = []; public function __call($name, array $argumentArray) { if (isset($this->propertyMap[$name]) && $this->propertyMap[$name] instanceof Closure) { return call_user_func_array($this->propertyMap[$name], $argumentArray); } throw new RuntimeException(); } public function __get($name) { return isset($this->propertyMap[$name]) ? $this->propertyMap[$name] : null; } public function __set($name, $value) { if ($value instanceof Closure) { $value = $value->bindTo($this); } $this->propertyMap[(string) $name] = $value; } } $magic = new Magic(); $magic->foo = 'hello'; $magic->bar = 'world'; $magic->dumpStuff = function () { var_dump($this->foo, $this->bar); }; $magic->dumpStuff();
Output for rfc.property-hooks, git.master, git.master_jit
string(5) "hello" string(5) "world"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.31 ms | 2639 KiB | 4 Q