- var_dump: documentation ( source)
<?php
class Foo
{
private $count;
public function __construct()
{
$this->count = 1;
}
public function addCount()
{
$this->count++;
}
}
class Bar
{
private $foo;
public function __construct()
{
$this->foo = new Foo;
}
public function getFoo()
{
return $this->foo;
}
}
$bar = new Bar;
$foo = $bar->getFoo();
$foo->addCount();
var_dump($bar->getFoo());
var_dump($foo);