PHP fclose() Function
Definition
The fclose() function closes an open file.
Syntax
PHP fclose() Function has the following syntax.
fclose(file)
Parameter
Parameter | Is Required | Description |
---|---|---|
file | Required. | Specifies the file to close |
Return
PHP fclose() Function returns TRUE on success or FALSE on failure.
Example
To close a file you have opened with fopen(), use fclose().
<?PHP/*from www . ja v a 2 s. c om*/
$filename = "c:/abc/test.txt";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
print $contents;
?>
In that example, fopen() is called with rb as the second parameter, for "read-only, binary-safe".