I have a PHP class that creates a PNG image on the fly and sends it to browser. PHP manual says that I need to make sure that imagedestroy function is called at end to release the memory. Now, if I weren't using a class, I would have some code like this:
function shutdown_func()
{
global $img;
if ($img)
imagedestroy($img);
}
register_shutdown_function("shutdown_func");
However, I believe that appropriate place for my class would be to place a call to imagedestroy in class' destructor.
I failed to find out if destructors get called the same way shutdown functions does? For example, if execution stops when user presses the STOP button in browser.
Note: whatever you write in your answer, please point to some article or manual page (URL) that supports it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…