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

Instructions for using the php fgetc() function

怪我咯
Release: 2023-03-13 13:10:02
Original
1943 people have browsed it

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)
Copy after login

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);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template