- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
fclose() function in PHP
The fclose() function closes an open file pointer. The function returns TRUE on success and FALSE on failure.
Syntax
fclose(file_pointer)
Parameters
file_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().
Return
The fclose() function returns.
- TRUE on success
- FALSE on failure
Example
<?php $file_pointer = fopen('amit.txt', 'r'); fclose($file_pointer); ?>
Output
true
Let us see another example. This shows a file which is opened, the content is returned using fgetsss and the file is closed with file pointer using file pointer.
Example
<?php $file_pointer = @fopen("/documents/new.php", "r"); if ($file_pointer) { while (!feof($file_pointer)) { $buffer = fgetss($file_pointer, 1024); echo $buffer; } fclose($file_pointer); } ?>
Output
This is demo text
- Related Articles
- file_exists() function in PHP
- basename( ) function in PHP
- chgrp()function in PHP
- chmod() function in PHP
- chown() function in PHP
- clearstatcache() function in PHP
- copy() function in PHP
- delete() function in PHP
- dirname()function in PHP
- disk_free_space() function in PHP
- disk_total_space() function in PHP
- diskfreespace() function in PHP
- feof() function in PHP
- fflush() function in PHP
- fgetc() function in PHP

Advertisements