SplFileObject::fgetc
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
Gets character from file
Description
SplFileObject::fgetc(): string|false
Gets a character from the file.
Parameters Parameters
Return Values
Returns a string containing a single character read from the file or false on EOF.
Falseproblem
Examples
SplFileObject::fgetc example
php
<?php
$file = new SplFileObject('file.txt');
while (false !== ($char = $file->fgetc())) {
echo "$char\n";
}
?>See Also
SplFileObject::fgets