Methods for instatiating an object

From: Date: Wed, 12 May 2004 10:41:30 +0000
Subject: Methods for instatiating an object
Groups: php.general 
Request: Send a blank email to php-general+get-185966@lists.php.net to get a copy of this message
Hi all, It is not a big issue, but that is something that I never had clear. I've been looking at the manual and found no answer, so I will ask with an example: When instantiating an object, I could do it in two different ways: A) $object = new MyClass; B) $object =& new MyClass; I cannot understand the exect difference betwen the two methods. Because there is not yet an object, the second example does not return a reference to an existing object. I think perhaps the diference is: 1) In case A, PHP creates a new object and returns a Copy of this new object, so really I will have the object two instances for the object in memory ... 2) In case B, PHP creates a noew object and returns a reference to this newly created object. In this case there is only one instance of the object. Does it works that way? If not, What is exactly the difference? TIA, Jordi.

« previous php.general (#185966) next »