Re: object refrences (POSSIBLE MAJOR BUG)
| From: | Robert Cummings | Date: | Thu, 11 Apr 2002 18:08:29 +0000 |
| Subject: | Re: object refrences (POSSIBLE MAJOR BUG) | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82609@lists.php.net to get a copy of this message | ||
Andrey Hristov wrote:
>
> But dereferncing like this
> $foo->bar()->fubar
> is feature of Z2 or not?
> Till today I didn't know that my 4.1.1(or 2) not sure can do this kind of dereferencing.
The above quote dereference involves an intermediate method, the one
described in the example below uses an object which is currently
supported.
> > $foo = new foo();
> > $foo->bar->set_tmp("outside foo");
> > $foo->variable = "foo";
As far as references go... I believe when you copy an object it is a
shallow copy, in otherwords, the object is copied, but not its members.
This behaviour is preferrable as far as I'm concerned. If you want a
deep copy try doing the following:
$foo = new foo();
$fee = unserialize( serialize( $foo ) );
That should provide a nice quick, clean solution for what you want while
not incurring the overhead most programmers would rather skip on every
object copy.
Cheers,
Rob.
--
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer |
:----------------------------------------------:
| Mail : mailto:robert.cummings@webmotion.com |
| Phone : (613) 731-4046 x.109 |
:----------------------------------------------:
| Website : http://www.webmotion.com |
| Fax : (613) 260-9545 |
`----------------------------------------------'