fgetc
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Gets character from file pointer
Description
fgetc(resource $stream): string|false
Gets a character from the given file pointer.
Parameters
streamAll
Return Values
Returns a string containing a single character read from the file pointed to by stream. Returns false on EOF.
Falseproblem
Examples
A fgetc() example
php
<?php
$fp = fopen('somefile.txt', 'r');
if (!$fp) {
echo 'Could not open file somefile.txt';
}
while (false !== ($char = fgetc($fp))) {
echo "$char\n";
}
?>