note 7976 added to fread

From: Date: Wed, 23 Aug 2000 02:44:27 +0000
Subject: note 7976 added to fread
Groups: php.notes 
Request: Send a blank email to php-notes+get-2942@lists.php.net to get a copy of this message
I'm trying to figure out whether a file exists given a URL. I'm doing it like this currently: ----------------- $fp = @fopen($url, "r"); $contents = fread ($fp, 1000000); if (!(ereg("404",$contents))) { fclose($fp); return "error404"; } else { fclose($fp); return "non error404"; } } ----------------- This is giving me inconsistent results. I tried just doing an fopen and checking whether the $fp was true or false, but problem is that the domain is always valid and I actually get data back (error 404) and $fp is NEVER false. My above implementation is working inconsistently. At times I get an errror says "file resource id is invalid" (or something along those lines). Can anyone help? http://www.php.net/manual/function.fread.php

« previous php.notes (#2942) next »