Re: Methods for instatiating an object
| From: | Mark Constable | Date: | Wed, 12 May 2004 10:48:09 +0000 |
| Subject: | Re: Methods for instatiating an object | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185967@lists.php.net to get a copy of this message | ||
On Wed, 12 May 2004 08:41 pm, Jordi Canals wrote:
> A) $object = new MyClass;
> B) $object =& new MyClass;
> 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?
You are quite correct...
http://php.net/references
--markc