Lets take the following two code samples:
$t1 = new MyObject("Moo");
$t1->doStuff();
$t2 = new MyObject("Baa");
$t2->doStuff();
and:
$t1 = new MyObject("Moo");
$t1->doStuff();
$t1 = new MyObject("Baa");
$t1->doStuff();
PHP appears to crash and burn on the second sample. OK, so you say use the first one. But lets say we want to do this:
$t[$index] = new MyObject("Moo");
// Some other code
$x = &$t[$index];
$t[$index] = new MyOtherObject($x->getAnimalNoise());
how would I achieve this? Would I need to "destory" the original object somehow? Or should PHP do this automatically?