Re: Redirecting HTML output to FILE
[email protected] (Erik Sogn) Wed, 01 May 2002 23:07:09 -0700
| Newsgroups | php.lang |
|---|---|
| Message-ID | <[email protected]> |
In addition, you may do something like this:
<?php
//Write output buffer to file.
function callback($buffer) {
$file = __FILE__ . '.static';
$head = '<!-- Contents of "' . $GLOBALS['PHP_SELF'] . '" -->' . "\n";
$head .= '<!-- Updated: ' . date("m/d/y @ H:i:s T") . ' -->' . "\n";
$fp = fopen($file, 'w');
fwrite($fp, $head);
fwrite($fp, $buffer);
fclose($fp);
return $buffer;
}
//Start buffering and call "callback" function when flushed.
ob_start('callback');
?>
<HTML>
<HEAD><TITLE>Buffer Test</TITLE></HEAD>
<BODY>
<? /* (this comment will dissapear) */ ?>
<P ALIGN="CENTER">This is a Test</P>
<P ALIGN="CENTER"><? echo date("D M j G:i:s T Y"); ?></P>
</BODY>
</HTML>
<?php
//Flush buffer.
ob_end_flush();
?>
-- Erik
Paul Padilla wrote:
>
> How would one go about redirecting the result of an HTML page to a file
> in the webserver instead of the client's browser? I am trying to parse
> out information from an HTML result page using PHP but don't know which
> PHP syntax to use to redirect the HTML result into a file.
>
> Cheers,
> Paul