3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $name = 'a'; private $value = null; public function __construct() { $this->value = 1; } } class B { public $name = 'b'; private $differentValue = null; public function __construct() { $this->differentValue = 1; } } class CD { private $parent = null; public function __construct($parent) { $this->parent = new $parent; } public function __call($name, $params) { if ( is_callable(array($this->parent, $name)) ) { return call_user_func_array(array($this->parent, $name), $params); } else { throw new Exception('Method "'.$name.'" should be callable.'); } } public function __get($property_name){ if(isset($this->$property_name)) { return $this->$property_name; } elseif (isset($this->parent->$property_name)) { return $this->parent->$property_name; } else { return null; } } public function display() { echo "OK"; } } $c = new CD(new B); var_dump($c->name);
Output for git.master, git.master_jit, rfc.property-hooks
string(1) "b"

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