English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP fclose() Function Usage and Example

PHP Filesystem Reference Manual

The fclose() function closes all open files, and returns true if successful; otherwise, it returns false.

Syntax

bool fclose ( resource $handle )

The file pointer must be valid and must point to a file successfully opened by the fopen() or fsockopen() function.

Online Example

<?php
   $handle = fopen("/PhpProject/sample.txt", "r");
   fclose($handle);
   echo "File closed successfully";
?>

Output Result

File closed successfully

PHP Filesystem Reference Manual