Re: use of = &new object versus = new object
| From: | Madeleine D. | Date: | Mon, 11 Jul 2005 18:42:29 +0000 |
| Subject: | Re: use of = &new object versus = new object | ||
| References: | 1 2 3 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5977@lists.php.net to get a copy of this message | ||
I think Jake has asked a very good question. Since he ran into his earlier
problem and removed the reference on the new objects, I've taken to trying
the same thing in my code. So far, I don't see a difference - either for
performance or for causing any kind of problems. My screens seem to behave
the same way, with or without the = & new.
I understand about references and how they work, but as he points out, all
of our GtkObjects are new items, and generally don't need references at
that point. So why do we do it??
Madeleine D.
At 07:13 PM 7/11/05 +0100, Jake Gordon wrote:
>Thanks for quick replies, but I still don't get it.
>
> > & is to force an reference of object, under PHP5 references are
>deprecated
>
>Okay, 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.
>
>--
>PHP-GTK General Mailing List (http://gtk.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>