Category Archives: PHP – File Read: getc Function

PHP – File Read: getc Function

The fgetc() file system function in PHP will return a single character read from a file that is opened using fopen() or fsockopen().

code

<?php
$file = fopen("myfile.txt", "r");
$character = fgetc($file);
fclose($file);
echo $character;
?>
OUTPUT
H

My file contents are “Hello World”. As you can see it returned one single character from that file.

Link One