php feof function

高洛峰
Release: 2016-11-29 15:04:13
Original
1203 people have browsed it

If the file pointer reaches EOF or an error occurs, it returns TRUE, otherwise it returns an error, including socket timeout, and in other cases, returns FALSE.

Syntax: feof(file)

Parameter description

file required, specifies the open to be checked File.

Note: The file parameter is a file pointer. This 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().

PHP example code As follows:

// if file can not be read or doesn’t exist fopen function returns false

$file = @fopen("no_such_file", "r");

// false from fopen will issue warning and result in infinite loop here

while (!feof($file)) {

}

fclose($file);

?>

$fh = fopen("/home/www.phpfensi.com/data/users.txt", "rt");

while (!feof($fh)) echo fgets($fh);

fclose($fh) ;

?>


Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!