Reply to file() doesn't work

Your name:

Reply:


Posted by Dave Moore on 12/28/05 21:54

Hi All,
Ok, here's my problem. I want to open a file and process its contents.
However, because it is possible that the file may not exist, I also want to
check whether the file() function is successful before attempting to process
any returned data from the file() function. The php file() manual page
suggests that it returns FALSE if it is unsuccessful, however this simply
doesn't happen on my system. My code looks like the following:


if (($file_contents =
(file("http://www.mydomain.com/some_file_that_doesnt_exist.dat"))) == FALSE)
{
echo "Your file doesn't exist!!";
}
else
{
do_some_interesting_processing ($file_contents);
}

Even something like the following doesn't work:

if (file("http://www.mydomain.com/some_file_that_doesnt_exist.dat") ==
FALSE)
{
echo "Your file doesn't exist!!";
return;
}

The file() function doesn't return FALSE as suggested.

So what's going on?. Why doesn't this work?. Is there another/better way of
knowing whether the file() function was successful?.

Regards,
Dave

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация