This is driving me nuts:
// determine if site exists
$fp = @fopen("http://plugh.arga34dsf.abc", "r");
if ($fp) {
echo "site exists";
fclose($fp);
}
else {echo "no site";}
$fp always returns true whether the site exists or not. If I reference an internal file (/usr/www/admin/file) it works correctly and will return false if the file is absent. I've also tried it without the @ symbol and the results are the same.
I know I can get a socket, because this works:
// copy webpage to a file
$fp = fopen("http://www.yahoo.com", "r");
$outhandle = fopen("site.html","wb");
while (!feof($fp)) {
$buffer .= fread($fp,4096);
}
fputs($outhandle, $buffer);
fclose($handle);
fclose($outhandle);
The code also executes correctly on my windows machine but fails on my FreeBSD webserver.
What could it be?
Thanks
Brad