SplFileObject::eof
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
Reached end of file
Description
SplFileObject::eof(): bool
Determine whether the end of file has been reached
Parameters Parameters
Return Values
Returns true if file is at EOF, false otherwise.
Examples
SplFileObject::eof example
php
<?php
$file = new SplFileObject("fruits.txt");
while ( ! $file->eof()) {
echo $file->fgets();
}
?>The above example will output something similar to:
output
apple
banana
cherry
date
elderberrySee Also
SplFileObject::validfeof()