Posted by amygdala on 04/12/07 21:10
I'm trying to figure out the correct use of references.
Lets say I have a class Validator and a class User. And I want to let a User
instance be an referenced object in Validator. Where would the best place be
to put the & sign, and why? (See the /* */ comments inside code)
class Validator
{
public function __construct( /* here? */ $caller )
{
$this->class =/* here? */ $caller;
}
}
class User
{
$private validator = NULL;
public function __construct()
{
$this->validator = new Validator( /* or here? */ $this );
}
}
Also, what would happen if were to put & signs in multiple places sprecified
in this particular example? Would it be redundant?
Thank you for any insight.
[Back to original message]
|