Re: Reading into a file problems

From: Date: Mon, 14 Aug 2000 02:19:20 +0000
Subject: Re: Reading into a file problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11545@lists.php.net to get a copy of this message
On 11 Aug, Paulson, Joseph V. "Jay" wrote: > Hey eveyone-- > > I'm having a bit of a problem reading into a file. What I am doing is > reading a web site and then line by line I want to read that site into > another file into my temp directory so I can re-open that file later on. > Below is a code snippet of what I am trying to do. What happens is I end up > with a huge file and all that is inside the file is rss.rdfrss.rdf over and > over again. I'm not sure what I'm doing wrong but any help would be great! > > $newsdir = "c:\\temp\\"; > $filename = "rss.rdf"; > > function readPage($url) { > global $newsdir, $filename; > $site = fopen("$url", "r"); > $fp = fopen($newsdir . $filename, "w"); > if (!$fp){ return; } //just quit on error > if ($site){ > while (!feof($site)){ > $line = fgets($site, (strlen($site)+1)); > fputs($fp, htmlEntities($line)); > } > } > fclose($fp); > } > > > Thanks! > Jay Paulson > I don't think strlen($site) is doing what you expect it to do. Replace that with a constant integer of a sufficiently large value to allow for virtually any line length. Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#11545) next »