On Wed, Sep 9, 2009 at 17:59, Daniel Convissor<dani...@analysisandsolutions.com> wrote: > 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.
I'm getting a bit confused here. The thread has been hijack now 3times so I'm no longer sure what we are talking about.. but.. There is absolutely no reason for the user to know all this when reading php.net/oop. The only time we should even consider sharing this with the users is when explicitly explaining why the documentations lie (i.e.: php.net/language.oop5.references). Please keep the lie alive. -Hannes