Actually, $this->db will be a copy of $dbObj. Here is what you have:
<?php $db = function2createDBObject(); Site($db); function Site(&$dbObj) { $this->db = $dbObj; } ?> What this means is that $dbObj is a reference to $db. However, $this->db is a copy. If you want $this->db to be a reference of $db, you have to create a reference to $dbObj. function Site(&$dbObj) { $this->db =& $dbObj; } Like that. Jason Lotito [EMAIL PROTECTED] www.NewbieNetwork.net > -----Original Message----- > From: Matt Friedman [mailto:[EMAIL PROTECTED]] > Sent: Sunday, December 09, 2001 1:34 PM > To: [EMAIL PROTECTED] > Subject: [PHP] - References Clarification Please - > > > Hi, > > I'm just trying to get my head around references and the uses > etc... I have reviewed the manual section on this a few times > but I'm still a bit fuzzy on it. > > First of all, here's some code I'm using to pass a reference > to an object (which has global scope) to the constructor of a > class "Site": > > function Site(&$dbObj) > { > $this->db = $dbObj; > } > > I think what should happen here is that $this->db is now a > reference to the global version of the object, by way of the > "&" in the function defn. Is this correct? > > Also, I'm not sure about the benefits of using references as > opposed to copies. If anyone would like to elaborate on the > reasons for using a reference instead of a copy, please do > so; it would be much appreciated. > > > Many Thanks, > Matt Friedman > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] To contact the list > administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]