The fgetc() function returns a single character from an open file.
PHP fgetc() Function has the following syntax.
fgetc(file)
Parameter | Is Required | Description |
---|---|---|
file | Required. | File to check |
PHP fgetc() Function returns a single character from an open file.
<?php
$file = fopen("data.txt","r");
echo fgetc($file);
fclose($file);
?>
Read file character by character:
<?php
$file = fopen("data.txt","r");
while (! feof ($file)){
echo fgetc($file);
}
fclose($file);
?>