Say that I am using the stream
resource type to open a file:
$file = fopen('1.txt', 'w+');
If I want to destroy the resource, I would call fclose()
:
fclose($file);
But I think that fclose()
only destroys the resource and not the variable itself, I know this because when I do the following:
<?php
$file = fopen('1.txt', 'w+');
fclose($file);
xdebug_debug_zval('file');
?>
I get the following result:
file:
(refcount=1, is_ref=0),resource(3, Unknown)
Which means that the variable still exist in memory.
So should I call unset($file)
after calling fclose($file)
to destroy the variable?