PHP fgetc() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The fgetc() function returns a single character from an open file.
Syntax
fgetc(file)
| Parameters | Description |
|---|---|
| file | Required. Specifies the file to check. |
Tips and Notes
**Note:** This function is very slow on large files, so it should not be used for them. If you need to read one character at a time from a large file, use fgets() to read one line at a time and then use fgetc() to process the characters in that line.
Example 1
The code above will output:
H
Example 2
Read a file character by character:
The code above will output:
Hello, this is a test file.
Complete PHP Filesystem Reference Manual