fgetc
Read characters from file pointer
The fgetc()
function reads a character from the file pointer.
<?php $file = fopen ( "test.txt" , "r" ) ; echo fgetc ( $file ) ; fclose ( $file ) ; ?>
The output is similar:
H
<?php $file = fopen ( "test.txt" , "r" ) ; While ( ! feof ( $file ) ) { echo fgetc ( $file ) ; } fclose ( $file ) ; ?>
The output is similar:
Hello, this is a test file.
fgetc ( file )
parameter | describe |
---|---|
file | Required. Specify documents to be inspected. |
Returns a string containing a character obtained from the file pointed to by the file. If EOF is encountered, it returns false.
The file pointer must be valid and must point to a file that was successfully opened by fopen()
or fsockopen()
(but has not been closed fclose()
).