What is the syntax for returning a reference from a member function defined in an object.
From the PHP manual, here's how you do it with a regular function:
function &returns_reference() {
return $someref;
}
$newref =&returns_reference();
What is the analogous syntax when dealing with objects and their methods? This generates a parse error:
class myClass {
var $foo;
function &setFoo($bar) {
$this->foo = $bar;
return $this->foo;
}
}
$a = new myClass;
$b = $a->&setFoo("tomato"); // $b should be a reference to $a->foo
echo $a->foo; // should print "tomato"
$b = "potato";
echo $a->foo; // should print "potato"
Writing $a->setFoo("tomato") (removing the ampersand) parses but doesn't work.
Thanks for any help!
-dave