|
|
Posted by woger151 on 04/30/07 14:35
If I write
$x = new some_class($init_data1);
and then
$x = new some_class($init_data2);
does the first object (constructed with $init_data1) get destroyed, or
do I have to call unset() for that? And am I guaranteed that after
the second call the value of $x will be as if the first call was never
made?
I tried using var_dump within a for loop to see what was happening
(ie, using "new" and assigning it to the same variable name everyt
ime), and in the printout I get stuff like
object(some_class)#1
alternating with
object(some_class)#2
If I call unset(), I don't get the #2. I'm assuming that (in the case
I don't call unset()) PHP is destroying the variable every other
iteration due to some kind of garbage collection algorithm. And the
"#1" and "#2" refer to the actual object being referenced.
TIA
Navigation:
[Reply to this message]
|