Re: Re: Strange notation to create object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Robert Cummings <robert@xxxxxxxxxxxxx> :
> On Thu, 2005-06-23 at 15:28, Matthew Weier O'Phinney wrote:
> > * Robert Cummings <robert@xxxxxxxxxxxxx> :
> > > On Thu, 2005-06-23 at 13:36, Matthew Weier O'Phinney wrote:
> > > > * Robert Cummings <robert@xxxxxxxxxxxxx> :
> > > > > On Thu, 2005-06-23 at 11:32, Matthew Weier O'Phinney wrote:
> > > > > > The above notation is unnecessary when developing in PHP5, as objects in
> > > > > > PHP5 are passed by reference by default. However, in PHP4, this was
> > > > >
> > > > > Not entirely, there's still a subtle difference in PHP5 between
> > > > > assigning an object with = versus assigning with = &.
> > > > 
> > > > Would you mind explaining the difference? I've seen nothing in the docs,
> > > > to indicate that assigning objects with =& in PHP5 is necessary, or even
> > > > desired. My experience with PHP5 hasn't shown this either. I'd be
> > > > interested to know to what you refer.
> > >
> > > See for yourself when running the following script:

<snip -- code sample>

> > 
> > This doesn't demonstrate what the OP was talking about, which is initial
> > assignment of an object using a reference operator. The results of this
> > make perfect sense to me -- the references are passed exactly as I would
> > expect. 
> > 
> > Let me rephrase my question to you: is there a reason to do the initial
> > object assignment using a reference operator using PHP5? I.e., is there
> > a good reason to do this:
> > 
> >     $foo =& new Foo();
> > 
> > instead of:
> > 
> >     $foo = new Foo();
> > 
> > I haven't seen any reason to do the former case using PHP5.
>
> Your original response said that the above notation was unneccessary, I
> took that to mean the & operator for reference. Looking back I see ow
> that your comment was ambiguous, and I agree there is no need for the &
> when assigning a new object. I was merely clarifying that references and
> normal assignment are not synonymous for objects in PHP 5.

Okay -- good to see that we're on the same page. I was worried I'd
missed something critical in the manual!

References aren't easy to wrap your head around; I, for one, am very
happy that I don't need to worry about them nearly as much with PHP5
(syntax is now, "do what I mean").  Interestingly enough, however, the
PHP4 behaviour is actually much closer to perl's -- which should have
made it easier for me (being a perl programmer), but somehow didn't.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux