My apologies... this examples better clarifies your point and I must admit
that it is rather strange behaviour :) And I think I forgot that PHP does
do deep copies, probably because I'm so used to writing wrapper objects
with references to my real objects so I automate shallow copies.

Cheers,
Rob.

brad lafountain wrote:
> 
> 
>  I do understand the difference... but it also doesn't say it does a shallow
> copy. because it DOES do a deep copy.... run the following code..
> 
> <?
> class foo
> {
>  function foo()
>  {
>   $this->bar = new bar();
>  }
> }
> 
> class bar
> {
>  function bar()
>  {
>   $this->tmp = "bar";
>  }
>  function do_nothing()
>  {
>  }
> }
> 
> // As you see no shallow copy!!
> $foo = new foo();
> $foo->bar->tmp = "test";
> $foo2 = $foo;
> $foo2->bar->tmp = "foo";
> var_dump($foo);
> var_dump($foo2);
> 
> // now....
> $foo->bar->do_nothing();
> $foo3 = $foo;
> $foo3->bar->tmp = "bug";
> var_dump($foo);
> var_dump($foo3);
> ?>
> 
> as soon as a function is called from a objects member.. this is where the
> refrence is created!
> 
>  - Brad

-- 
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer  |
:----------------------------------------------:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109                 |
:----------------------------------------------:
| Website : http://www.webmotion.com           |
| Fax     : (613) 260-9545                     |
`----------------------------------------------'

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to