Re: Re: Strange notation to create object

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

 



Matthew Weier O'Phinney wrote:
...

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.

But not exactly as I would expect! I thought that all objects were created as references, but apparently this is not the case. Is there some kind of dereferencing going on when you're using an object on the right side of the assignment (=) operator?

In any case, assignment without & is a tricky thing to look out for and certainly can produce some really hard to detect bugs. If the people that have been using PHP for years don't fully understand this... *whistling and walking away*

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.


Neither have I...

Slightly on-topic: I was browsing through PECL today and found an interesting looking extension called "parsekit". It will take your PHP code and show what the underlying opcodes are. If I find some time tonight I'm going to play around with this extension and see if I can figure out how references are being handled by the engine.

P.S. Windows users: save your sanity and just get the .dll version instead of trying to build from source. :)

http://snaps.php.net/win32/PECL_5_0/

--
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php

--
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