The fclose() function is used to close an open file:
<?php
$file = fopen("test.txt","r");
//some code to be executed
fclose($file);
?>
After a file has been closed down with fclose it is impossible to read, write or append to that file unless it is once more opened up with the fopen function.