| This article introduces how to close opened files in php programming. For more information, see.
In php, after opening a file for related operations, you need to close the file handle in time to avoid occupying resources for a long time.
Php closes a file
In php programming, it is a good habit to close a file in time after it is used up.
Php functions or methods for disabling files
To close a file in php, you need to use the fclose function.
The following is an example of closing a file for your reference.
Code:
Code description: the fclose function requires a file handle to be closed. In the above example, we set the variable "$ ourFileHandle" to the file handle returned by the fopen function.
After the initial operation, the opened file testfile.txt is closed, and then the operation such as reading or appending the file content will be invalid. The preceding operations can be continued only when the access file is opened again.
This article describes how to close files in php. I hope it will be helpful to you. |