Problem with ob_get_contents()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I've posted a miniature version of my code here to explain my problem.

<CODE>

<?
phpinfo();

ob_start();

register_shutdown_function("hello");

echo ("HELLO");

die();

function hello()
{

$logfile = "logfile";

$error_string = ob_get_contents();

if(!$handle = fopen($logfile, "a"))
{
        echo("Could not open logfile for writing!");
        ob_end_flush();
        exit;
}

if(fwrite($handle, $error_string) === FALSE)
{
        echo("Could not write to logfile!");
        ob_end_flush();
        exit;
}

fclose($handle);

ob_end_clean();

}

?>

</CODE>

This simply does not work the way it should. i.e ob_get_contents doen't return 
any string and the buffer just gets flushed by itself at termination.

Though the PHP manual says it is not possible to retrieve the contents of any 
output buffers using ob_get_contents() with PHP < 4.0.6. But I am using PHP 5.
x.x

Thanks in advance for any help.

Prathap

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux