Re: Redirecting HTML output to FILE
[email protected] ("Kresimir Kondza") Fri, 29 Mar 2002 19:32:09 +0100
| Newsgroups | php.lang |
|---|---|
| Message-ID | <[email protected]> |
Easy
Just open the url you get with fopen function but instead of "w" parameter
use "r" one.
This loads the HTML output you get just as if you opened it in broeswer.
Then you read that file line by line and put it into an array nad write it
back to you file.
For that you could use another function that opens a file on url and auto
loads it in array. here is simple examle:
$fp=fopen("local addres of file in wich you write");
$file_on_url=file(http://file url);
foreach ($file_on_url as $line){
fputs($fp,$line ."\n"); // writes the line and puts the write
pointer to new line
}
fclose ($fp);
this should do the trick.
"Paul Padilla" <[email protected]> wrote in message
news:[email protected]...
> Hi Kresimir,
>
> Thanks for the reply but I have a PHP URL with a GET method that
> returns a page based on the parameters passed. How do I capture the
> resulting page to a variable or to a file?
>
> Cheers,
> Paul
>
>
> In article <[email protected]>, Kresimir Kondza
> wrote:
>
> > in this case you use file functions.
> >
> > first you open a file with
> > $fp=fopen("local file adress","w"); // opens a file for writing
> >
> > then you put some text into a var
> >
> > $file_content="This is content of the file you are cretaing";
> >
> > and then you print this to file
> > fputs($fp,$file_content);
> >
> > and you close the file
> > fclose($fp);
> >
> > that's it
>
>