PHP fgetc() function

fgetc() function : Reading a File Character by Character

The fgetc() function is used to read a single character from a file.

Note: After a call to this function the file pointer moves to the next character.

Example

The example below reads a file character by character, until the end of file is reached:

<?php
$file=fopen("welcome.txt","r") or exit("Unable to open file!");
while (!feof($file))
 {
 echo fgetc($file);
 }
fclose($file);
?>

No comments:

Post a Comment