Re: use of = &new object versus = new object
| From: | Jake Gordon | Date: | Mon, 11 Jul 2005 18:13:13 +0000 |
| Subject: | Re: use of = &new object versus = new object | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5973@lists.php.net to get a copy of this message | ||
Thanks for quick replies, but I still don't get it.
& is to force an reference of object, under PHP5 references are deprecatedOkay, but its creating a *new* object, so what exactly is it referencing? (PS, i'm using PHP4) Also...
in PHP the & means pass by reference. In PHP 4 it passes objects by value
which means when you do $var = new obj(); $var 1 = $var; when it assigns var 1 it actually copies the entire $var object, if you were
to use $var = new obj(); $var 1 = &$var; it would assign the reference rather than copy the whole object.I understand the use of the & in your example, but in your example you're not using the & in the = &new line but the one below. I still don't understand when I should use it and when I shouldn't in creating new objects. Thanks, Jake.