quick check - by ref vs by value with objects

From: Date: Fri, 28 Feb 2003 09:26:34 +0000
Subject: quick check - by ref vs by value with objects
Groups: php.general 
Request: Send a blank email to php-general+get-137530@lists.php.net to get a copy of this message
Hi guys, If I have an object that has another object as a variable (eg, a dbConn object), then I create another object and pass this dbConn in the constructor, if that second class sets that arg to it's own variable, is it true in 4.3.1 that they will NOT be sharing the same object reference? I this I think is different in the zend 2.0 engine - see here: http://www.zend.com/images/press/Feb_2003-4_Zeev_PHP5.pdf But anyway, if I want each of the 2 classes to each point to the same dbConn object, does that mean I have to write the constructor as function secondClass(&$dbConn) { $this->db = $dbConn; } ? cheers, neko

« previous php.general (#137530) next »