Re: Reassigning variable to new object destroys old one?



ZeldorBlat wrote:
The object is automatically destroyed when nothing is referencing it.
When you assign the second instance to $x, there is nothing left
referencing the first instance.

There was another thread on this subject recently:
<http://groups.google.com/group/comp.lang.php/browse_frm/thread/
7046181c4c507263/3e766edeeebbd5f5#3e766edeeebbd5f5>


At the risk of starting the $a++ thread again ... hehe

I believe that will be why $a = $a++; doesn't work.

The PHP manual should say $a++ "Returns value of $a" not "Returns $a..."
which to me infers it returns itself as a reference and the ++ should work.

But, returns value of a, hence $a overwrites itself, and the ++ tries to take effect on the original which now has no references so doesn't exist.

Umm... Monday afternoon.. I'm bored and perplexed at the same time.

I don't think that helped you, sorry. I'll get my coat.
.



Relevant Pages