Quote:
> I've a application that generates html on the fly - the normal way of
> doing things. However I need it to also write to a file on the server
> - in a protected directory, for archival purposes. Q. can the
> printf() function be directed to write to a file, after using fopen()
> of course, or using a Unix '>> outfile' construct. Or printf() to a
> stringVariable then I could fputs() it to the file.
Consider also output buffering.
http://www.php.net/manual/en/function.ob-start.php
ob_start (); // before any page generation
// output html on the fly
$content = ob_get_contents(); // store html in a variable
ob_end_flush(); // flush the contents to the browser
$fp = fopen('somefile.bak', 'w');
fwrite($fp, $content);
fclose($fp);
The above code should store a duplicate of the file served to the browser.
(untested)
regards,
reggie.