Re:PHP doesn't need 'finally'
by TimJYoung on Friday December 10, 2010 @08:35PM
(#1993873)
Thanks for the response. I knew that PHP was reference counted, but what I was asking (not particularly well) was more along the lines of: is it possible to have objects live longer than the scope of a single script ? IOW, is there a point at which the PHP runtime decides that it is going to collect/reclaim everything, similar to a process termination in the OS ? Or is it literally possible to implicitly allocate objects in a global fashion and have them stick around until the PHP runtime itself is terminated ? Thanks again.
[ Parent
| on HN ]
When a single script terminates, all the memory is deallocated. Basically, as you said, it's just like process termination in the OS.
Re:PHP doesn't need 'finally'
by dan_netwalker on Tuesday December 14, 2010 @01:25PM
(#2005135)
Well, in fact you could serialize/unserialize the objects and store them somewhere, making use of the "magic" functions __sleep() and __wakeup(), if I recall correctly. But yes, as soon as the web server ends the response or the script gets to the end, it's finished