Re: fgets()

From: Date: Mon, 04 Nov 2002 07:50:59 +0000
Subject: Re: fgets()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-122634@lists.php.net to get a copy of this message
Khalid El-Kary wrote: > hi, > i want to open a remote file using fopen() i tried both of these ways > > $filename="http://www.domain.com/filename.txt"; > $file=fopen($filename,"r"); > $filecontents=fread($file,filesize($filename)); > > this one didn't work because it's apparent that the file isn't in the > local file system so filesize($filename) won't work ... > > the second way was this: > > $filename="http://www.domain.com/filename.txt"; > $file=fopen($filename,"r"); > $filecontents=""; > while (!feof($file)) > { > $filecontents.=fgets($file); > } > > this one worked well with PHP4.2.3 but with versions under PHP 4.2.0 > it didn't work > > So what else can i try to just get the whole contents of the file > into a string? $filename = http://www.domain.com/filename.txt; $fp = fopen($filename,"r"); while (!feof($file)) $content .= fread($fp,4096); HTH Erwin

« previous php.general (#122634) next »