0

Syntax

string fgetc ( resource $handle );

Definition and Usage

Gets a character from the given file pointer.

Paramters

ParameterDescription
handleThe file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).

Return Value

Returns a string containing a single character read from the file pointed to by handle. Returns FALSE on EOF.

Example

Following is the usage of this function:

<?php
$fp = fopen('example.txt', 'r');
if (!$fp) {
    echo 'Could not open file somefile.txt';
}
while (false !== ($char = fgetc($fp))) {
    echo "$char\n";
}
?>

Post a Comment

 
Top