3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class B { private $b; private $text; public function __construct($b) { $this->b = $b; } public function getText() { return $this->text; } public function setText($text) { $this->text = $text; } } class A { private $b; public function b() { return isset($b) ? $b : new B($this); } } $a = new A; $a->b()->setText('test'); echo $a->b()->getText();
Output for 5.3.22 - 7.3.0beta1