From: "Andy Jones" <[EMAIL PROTECTED]>

> Hi
>
> I'd normally start this mail with some background of what I'm doing,
> but to save everyone time, I'll start with the questions, and then
> in case anyone has alternative suggestions or workarounds, I'll
> fill in the what I'm doing and why...
>
> Within PHP script, is it possible to
>
>  1.  capture the results of the PHP engine's processing of
>      the current .phtml/.php file?
>      ie. what the server will sent back to the browser.
>
>  2.  manually feed a (possibly different) .phtml/.php file into
>      the PHP parser and obtain the results of the processing?
>
>


Yes this is possible, in a way. I have done it before, for a simple caching
mechanism.

Try this:


<?php
    ob_start(); // turn on output buffering
    echo "<html>";
?>

Some <b>page text</b>!

<?php
    echo "</html>";

    // now save the buffer to a file
    $fp = fopen("/usr/local/apache/htdocs/file.html", "w")
        or die("eek");
    fwrite($fp, ob_get_contents());
    fclose($fp);

    // and output the buffer to the browser
    ob_end_flush();
?>


And have a flick through:
http://www.php.net/manual/en/ref.outcontrol.php


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to