3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $bar; public function setBar($bar) { $this->bar = $bar; } public function getBar() { return $this->bar; } public function setName($name) { $this->getBar()->name_from_get = 'Baz'; $this->bar->name_directly = 'Baz'; } } $f = new Foo(); $f->setBar(new \stdClass()); $f->setName('Baz'); var_dump($f->getBar());
based on GKi9j
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
object(stdClass)#2 (2) { ["name_from_get"]=> string(3) "Baz" ["name_directly"]=> string(3) "Baz" }