[nycphp-talk] Pass-by-value and lazy copy
Gary Mort
bz-gmort at beezifies.com
Thu Nov 22 08:34:02 EST 2007
So, in the pass by reference talk, it was pointed out that if you do:
$a = 100;
$b = 100;
// At this point in time, $a and $b are still using the same memory to
store their data
$b=50;
// Now b is assigned it's own memory area since it changed the data
How does this work with objects? For example:
$a->foo = "Foo";
$a->foobar = "Foobar";
$b = $a;
// at this point in time, their using the same memory location for their
variables
$b->foobar="New Foobar";
// Is the entire object for $b copied to a new memory location, or is
just $b->foobar given it's own memory?
More information about the talk
mailing list