3v4l.org

run code in 300+ PHP versions simultaneously
<?php class KeyValuePairs { private $pairs; public function __construct( $arr = []) { $this->pairs = []; foreach( $arr as $k => $k) { $this->pairs[$k] = $v; } } public function __get($name) { return (isset($this->pairs[$name])) ? $this->pairs[$name] : null; } public function __set($name, $value) { $this->pairs[$name] = $value; } } class MyClass { public $foo; public $bar; public function __construct() { $this->bar = new KeyValuePairs( ['tool' => 'Here we go']); } public function __get($name) { return (isset($this->$name)) ? $this->$name : null; } } $class1 = new MyClass; var_dump($class1->foo); // null var_dump($class1->boo); // null var_dump($class1->bar->tool); // 'Here we go' var_dump($class1->bar->mars);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $v in /in/u6MAb on line 10 NULL NULL NULL NULL

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:
40.13 ms | 401 KiB | 8 Q