note 8047 added to fopen

From: Date: Fri, 25 Aug 2000 02:50:10 +0000
Subject: note 8047 added to fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-3116@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.fopen.php

« previous php.notes (#3116) next »