3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private $a; function __construct($a) { $this->a = $a; } public function getA() { return $this->a; } } class B extends A { function __construct() { parent::__construct('foo'); } } var_dump($b = new B); class C extends A { function __construct(A $a) { $a->a = 'bar'; $this->a = 'baz'; } } var_dump(new C($b)); var_dump($b->getA());
based on sbLSK
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
object(B)#1 (1) { ["a":"A":private]=> string(3) "foo" } object(C)#2 (2) { ["a":"A":private]=> NULL ["a"]=> string(3) "baz" } string(3) "foo"