Re: Referrences
| From: | Markus Fischer | Date: | Mon, 03 Jun 2002 08:06:13 +0000 |
| Subject: | Re: Referrences | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-84746@lists.php.net to get a copy of this message | ||
On Mon, Jun 03, 2002 at 10:29:19AM +0300, Michael Stolovitzsky wrote :
> If I understand correctly, given $bar is an object
>
> $foo = $bar
>
> will copy entire contents of $bar into foo. Following question: what happens
> with $foo = new Foo? Does the object get created, copied into $foo and then
> destroyed, while the copy in $foo lives?
>
> In other words, is there a performance benefit to do $foo =& new Foo?
No, it's exactly the other way around with objects, you get a
slight performance penalty (though it may no be noticeable at
all).
Currently, not useing the '&' operator will always create a
new (shallow) copy of the objects.
This is already addressed with the new Zend Engine 2 which
will behave as expected (objects aren't copied, they stay
atomic until explicitely duplicated [cloned]).
- Markus
--
GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
Did I help you? http://guru.josefine.at/~mfischer/wishlist_en
Konnte ich helfen? http://guru.josefine.at/~mfischer/wishlist_de