In this article I describe the PHP FileSystem functions fflush, fgetc, fgetcsv and fgets. To learn some other filesystem functions, go to:
- FileSystem Function in PHP: PART 1
- FileSystem Function in PHP: PART 2
- FileSystem Function in PHP: PART 3
The PHP filesystem fflush function flushes the output to a file and it returns true on success and false on failure.
Syntax
| fflush(file) |
Parameter in fflush function
The parameter of the function is:
| Parameter | Description |
| file | It specifies the open file to check. |
Example
An example of the function is:
<?php
$filename = 'test.txt';
$file = fopen($filename, 'r+');
rewind($file);
fwrite($file, 'great day');
fflush($file);
fclose($file);
?>
PHP fgetc() function
The PHP filesystem fgetc function gets a character from the file pointer and this function returns a string containing a single character read from the file pointed to by the handle or returns false on EOF.
Syntax
| fgetc(file) |
Parameter in fgetc function
The parameter of the function is:
| Parameter | Description |
| file | It specifies the open file to check. |



Join the conversation! Your thoughts help the community grow.