Jump to content

feof() & fgets() failing me.


sepoto

Recommended Posts

I'm dealing with a big file that resides on a linux server running Fedora 14. feof() is failing me. It never returns false. fgets() is also failing me. It also never returns false. How can I go about finding the end of the file exactly?Thanks.

Link to comment
Share on other sites

I'm dealing with a big file that resides on a linux server running Fedora 14. feof() is failing me. It never returns false. fgets() is also failing me. It also never returns false. How can I go about finding the end of the file exactly?
If you are working in a MacOS, you might try turning on auto_detect_line_endings. When turned on, PHP examines the data read by the fgets() and file() functions to see if they are using Unix, MS-Dos, or Macintosh line-ending conventions.Roddy
Link to comment
Share on other sites

I'm dealing with a big file that resides on a linux server running Fedora 14. feof() is failing me. It never returns false. fgets() is also failing me. It also never returns false.
As follow-up to my last entry, if a connection opened by fsockopen() is not properly closed feof() will hang.Also, hopefully you do realize that the fgets() function reads only one line at a time, and that if you want to read all the way to the end of a file using the fgets() function, you will have to loop.Finally, if you are already at the end of the file, you might want to reset the file pointer to the beginning before trying to read it.Roddy
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...