Re: Re: fopen, fread

From: Date: Sat, 22 Sep 2001 16:40:23 +0000
Subject: Re: Re: fopen, fread
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68335@lists.php.net to get a copy of this message
Yeah, filesize() does not work with urls. Suggested file() and implode() earlier for this task and didn't mention fgets() as it may be appropriate here as well. http://www.php.net/fgets http://www.php.net/file Both manual entries have examples that do exactly what you want, "Put a url contents into a string." fgets() is nice because you don't have to gets the entire file, sticking a break; in there during a "match" can be uber cool :-) If this is being done locally then of course don't go through http:// ... Regards, Philip Olson On Sun, 23 Sep 2001, Simon Roberts wrote: > Check the value of filesize($fileName). It's probably not working - either > because PHP doesn't support it with URLs (likely) or that it's can't get the > length from the webserver (less likely). > > PS: don't cross-post this sort of message to php-dev. That's for people > developing PHP, not developing *in* PHP. > > ----- Original Message ----- > From: "CC Zona" <cczona@nospam.invalid> > To: <php-general@lists.php.net>; <php-dev@lists.php.net> > Sent: Saturday, September 22, 2001 4:32 PM > Subject: [PHP-DEV] Re: fopen, fread > > > > In article <20010921174303.5627.qmail@pb1.pair.com>, > > dries@plessers.com (Dries Plessers) wrote: > > > > > Can anybody tell me what is wrong. $file contains nothing ????? > > > > > $fileName="http://www.proxis.com"; > > > $fp=fopen($fileName, "r"); > > > $file=fread($fp, filesize($fileName)); > > > fclose($fp); > > > print("$file"); > > > > Not a good idea to just assume that every fopen will be successful (and > > therefore go ahead with the read) or that every fread will be successful > > (and therefore go ahead with the print). Throw some error checking in > > there, and PHP will likely tell you where the code is failing and why. > > > > -- > > CC > > > > -- > > PHP Development Mailing List <http://www.php.net/> > > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > > For additional commands, e-mail: php-dev-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#68335) next »