Quote:
Originally Posted by jamiek
Is this just good practice Ronnie?
|
Um, yes.
Technically the opendir() function returns a handle to an object in memory.
You can use that handle to perform other functions, such as readdir($handle).
When you are done with the handle, discard it by closing it. This removes the object from memory.
If not discarded, the object remains in memory. Every call to this part of the code creates another object, which in turn gets added into memory. And so on.
Imagine the page that this portion of code resides on all of a sudden winds up on the front page of Digg. What do you think will happen with a surge of page hits and that handle is not closed properly?
|