Hi all,

to quote from http://www.php.net/manual/en/function.ob-start.php

> void ob_start ( [string output_callback])
>
> An optional output_callback function may be specified. This function
> takes a string as a parameter and should return a string. The function
> will be called when  ob_end_flush() is called, or when the output
> buffer is flushed to the browser at the end of the request.

My callback function does not get called unless I manually call
ob_end_flush().

I'm not interested in calling ob_end_flush() at all,  I want my callback
function to be called "when the output buffer is flushed to the browser
at the end of the request" so the question is why isn't this happening?

here's my example:

<?php

$x = new test();

echo "hey";

// IF next line is uncommented so it manually flushes
// then the finish method WILL get called. But I need
// get around calling anything at the *end* of a script.

//ob_end_flush();


class test {

var $msg_file = "cooked_html/error_log2";

    function test() {
    ob_start(array(&$this, "finish"));
    $this->msg("got to initialize");
    }

    function finish($page) {
    $this->msg("GOT TO FINISH!!!");
    return $page;
    }

    function msg ($msg) {
    $msg = "\n" . exec("date") ." ::: ". $msg;
    $fp = fopen($this->msg_file, "a") or die ("cannot open ".$this->msg_file);
    fputs ($fp, $msg, strlen($msg)) or die ("cannot write to ".$this->msg_file);
    fclose($fp);
    }

}

?>


But if ob_end_flush() IS called then the error log WILL have the "GOT TO
FINISH" message.

Any ideas on why the output is not being flushed automatically?
thanks
Alex




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to