Voting

: six plus one?
(Example: nine)

The Note You're Voting On

vcoletti at tiscali dot it
8 years ago
With PHP 7.0 on Ubuntu 17.04 and with the option allow_url_fopen=On, file_exists() returns always false when trying to check a remote file via HTTP.

So
$url="http://www.somewhere.org/index.htm";
if (file_exists($url)) echo "Wow!\n";
else echo "missing\n";

returns always "missing", even for an existing URL.

I found that in the same situation the file() function can read the remote file, so I changed my routine in

$url="http://www.somewhere.org/index.htm";
if (false!==file($url)) echo "Wow!\n";
else echo "missing\n";

This is clearly a bit slower, especially if the remote file is big, but it solves this little problem.

<< Back to user notes page

To Top