Home  >  Article  >  Backend Development  >  Instructions for using the php fgetc() function

Instructions for using the php fgetc() function

怪我咯
怪我咯Original
2017-07-10 17:09:001923browse

fgetc() FunctionReads a character from the file pointer. The function may return the boolean value false, but it may also return a non-boolean equivalent of false, such as 0 or "".

Syntax

fgetc(file)

Parameters file Required. Specifies the documents to be checked.

Returns a string containing one character obtained from the file pointed to by file. Returns false if EOF is encountered.

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 by fclose()).

Code Example

<?php
$fh = @fopen("test.txt","r") or die("打开 test.txt 文件出错!");
if($fh){
    while(!feof($fh)) {
        echo fgetc($fh);
    }
}
fclose($fh);
?>

The above is the detailed content of Instructions for using the php fgetc() function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn