As you have unlocked a file and have completed your task, it is the time to close it. It is necessary to close a file when it is not needed. Otherwise, it will give you a tough time.
Explanation of File Close in PHP:
If we have to close a file in PHP, then it needs the execution of a code. Otherwise, the file will not get closed and may get some kind of faults in it. So, it is better to make your files close after using them. It will save you from many troubles.
Function of finishing a File in PHP
We have to use the fclose as a function which will make our file to close. Here is an example for your easiness.
Code of PHP
$newFileHandle = fopen($newFileName, 'w') or die("file can not open");
File handle is needed for the function fclose. It will help in closing a file. In this example, the variable $newfilehandle is equivalent to file handle which we have got back from the function fopen.
It should keep in mind that we can not write, edit or read from a specific file, if it has been closed. If we have to make any change in the file, then we have to open it.