Hi Greg:
> Copy-on-write still happens, the example you gave doesn't change a
> variable, only a property.
Yeah.
> A better comparison would be between arrays and objects, as this
> demonstrates that they behave differently in PHP 5, but were the same in
> PHP 4
>
> <?php
> $a = array('m' => 'foo');
> $b = $a;
> $a['m'] = 'bar';
> echo \"$a[m] = $a[m], \$b[m] = $b[m]\n";
[Flip the \ and the ", of course]
I was thinking of this same example as soon as I read your opening
sentence. :) The output from that is:
$a[m] = bar, $b[m] = foo
Meaning copy-on-write was in full effect. $a and $b became different
zvals.
> class not_copy_on_write {
> public $m = 'foo';
> }
> $a = new not_copy_on_write;
> $b = $a;
> $a->m = 'bar';
> echo "\$a->m = $a->m, \$b->m = $b->m\n";
The output of this is:
$a->m = bar, $b->m = bar
As we all know, copy-on-write is not the scenario here. $b is still
linked to $a.
I'm not sure how to word all of these explanations in the manual's text,
but we definitely need simple examples in there to demonstrate how things
work.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409