ID:               32665
 Updated by:       [EMAIL PROTECTED]
 Reported By:      prathap at ee dot pdn dot ac dot lk
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Gentoo Linux
 PHP Version:      5.0.3
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:
------------------------------------------------------------------------

[2005-04-12 09:58:47] [EMAIL PROTECTED]

It has been already documented: "There is currently no way to process
the data after the request has been completed."

I tried to clarify it to: "There is currently no way to process the
data with output buffering functions in the shutdown function."

------------------------------------------------------------------------

[2005-04-11 17:53:28] [EMAIL PROTECTED]

It should be said in manual that you can't use ob_* functions in the
shutdown funcs since the ob-stuff is already ended before we run
these.


------------------------------------------------------------------------

[2005-04-11 08:24:05] prathap at ee dot pdn dot ac dot lk

Description:
------------
Hello, 

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

<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 


I posted this problem in the mailing list and I got this response from
skrol29:

I've tested your code on PHP 4.3.3 and I have the same behavior has
yours. 

"Hello" is output at the end of the PhpInfo data, followed by a PHP
notice : 
  Notice: ob_end_clean(): failed to delete buffer. No buffer to delete.
in 
... 
And there is an empty "logfile" file created in the Apache directory
insteaf 
of the script's directory. 

If you change in your script: 
*********** 
 register_shutdown_function("hello"); 
 echo ("HELLO <br>"); 
 die(); 
*********** 
by 
*********** 
 // register_shutdown_function("hello"); 
 echo ("HELLO <br>"); 
 hello() 
 die(); 
*********** 
then it runs as expected and the "logfile" file is created in the
script's 
directory. 

It seems that when calling the shutdown function, all the buffered
output is 
immedialty sent to the client and the buffer mode is closed. 
You maybe have PHP bug here, or the manual is wrong about the
possibility to 
retrieve the contents. 
But we can notice that this also happens at the end of a script when
there 
is no shutdown function.



----

I am still not sure if this is a bug. But I would be very grateful if
someone generously volunteers to see to this.

Thank you and congrats on for the good work you have been carrying on
all throughout.

Prathap



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32665&edit=1

Reply via email to