Reading into a file problems
| From: | Paulson, Joseph V. \"Jay\" | Date: | Fri, 11 Aug 2000 23:10:43 +0000 |
| Subject: | Reading into a file problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-11430@lists.php.net to get a copy of this message | ||
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