Quite often I here, that people don't understand, how to use variables by reference. PHP is not an exception. This will be a very short post in which I will try to make it clear.
First of all we will define simple object class A
.
class A { protected $foo; public function __toString() { return $this->getFoo(); } public function setFoo( $foo ) { $this->foo = $foo; } public function getFoo() { return $this->foo; } }