Reputation: 281
Is it possible to check whether a file is completed(EOF) or is partially(corrupted)
I try :
$_file = @fopen($filePath, "r");
$isComplete = feof($_file);
fclose($file);
but it return empty.
Upvotes: 1
Views: 3294
Reputation: 16495
You can use a while(){}
loop for that, as:
$fh = fopen("alphabets.txt", "r");
while (!feof($fh)) {
$line = fgets($fh);
echo $line . "<br/>";
}
echo 'File is completed <br />';
Which will obviosuly iterate through the file's line one by one and exits as it reaches the end
I assuming your file contains a letters from a-h, this will be your output
a
b
c
d
e
f
g
h
File is completed
Upvotes: 2