file_exists quirk

Greetings, and thanks for having a look. I have a script that is taking a look at a file over the internet to parse data. Easy enough, sure. I keep a logfile of the script activity. No problem. I’m using file_exists to check and make sure the file is acessible, and if it’s not, put a message in the log file. It basically looks like this:

$file = "http://..."; if (!file_exists($file)) { do this... }

That is fine if the file is actually unreachable (http failure). However, if the file exists but it empty (0k), the bool is returned as false and puts the error in my log file. Technically I would call this an error with the file_exists function, as I see a 0k file as existing but with no characters in it, but that is not an argument I think I can make! My question is, is there a way to accomplish this with a php function that will not trigger a false on a 0k file? Thanks very much!

Sponsor our Newsletter | Privacy Policy | Terms of Service