Copyright © tutorialspoint.com
| string fgetc ( resource $handle ); |
Gets a character from the given file pointer.
| Parameter | Description |
|---|---|
| handle | The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()). |
Returns a string containing a single character read from the file pointed to by handle. Returns FALSE on EOF.
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";
}
?>
|
Copyright © tutorialspoint.com