faqts : Computers : Programming : Languages : PHP : Common Problems : Caching

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 12 people (92%) answered Yes
Recently 4 of 5 people (80%) answered Yes

Entry

How can I write the resulting HTML from a PHP script to a file?

Aug 10th, 1999 10:23
Nathan Wallace, Shantonu Sen, Robert Aden, gigandet@eurecom.fr


Try the following script which writes the result of a second PHP script
to a file.

    <?php               
    $filename = "http://servername/admin_prob.php3?id=2";
    $filename2 = "/tmp/zzz.html";
    $fd = fopen( $filename, "r" );
    $fd2 = fopen($filename2, "w");
    while (!feof($fd)) {
        $line = fgets($fd, 1024);
        fputs($fd2,$line);
    }
    fclose($fd);
    fclose($fd2);
    ?>

Alternatively if you're just trying to get the output to a file, and
you're using unix, you can try using lynx and the -source flag:

    lynx -source http://domain.com/path/test.php3?variable=3 >temp.html

the url might need quotes. you can set up a script to sequentially pass
all the variables.