ID: 44725
Comment by: vesselin dot atanasov at gmail dot com
Reported By: hack988 at gamil dot com
Status: Open
Bug Type: Apache2 related
Operating System: CentOS release 5
PHP Version: 5.2.6RC5
New Comment:
Actually for text block being output with a print statement it prepends
the length of the text block as a hex string followed with a CRLF. So
the following script:
------------------------------
<?php
echo "zzzzzzzzzzzzzz";
flush ();
echo "qqq"
?>
------------------------------
will output:
------------------------------
e
zzzzzzzzzzzzzz
3
qqq
0
------------------------------
Previous Comments:
------------------------------------------------------------------------
[2008-06-12 10:31:06] vesselin dot atanasov at gmail dot com
I can confirm that flush outputs superfluous characters. Actually I can
reproduce it with a much simpler script:
<?php
flush ();
?>
In my case I too get a superfluous "0" (without the double quotes).
------------------------------------------------------------------------
[2008-04-14 18:27:46] hack988 at gamil dot com
Description:
------------
flush function output for html body in some times.it disappear at begin
and end of html body.
exsample code:
<?php
define('XML_RPC', TRUE);
$XMLRPCVersion="1.0";
flush();
exit;
....more code
?>
it display:
0
<?php
define('XML_RPC', TRUE);
$XMLRPCVersion="1.0";
ob_flush();
exit;
....more code
?>
it display nothing
compare with to http headers i found that:
"Content-Length: 0"
exist when use ob_flush but not exist in flush
so i add this in my php codes like this
<?php
define('XML_RPC', TRUE);
$XMLRPCVersion="1.0";
header("Content-Length: 0");
flush();
exit;
....more code
?>
now all thing is work will!
i download php source code an compare flush with ob_flush.
in ob_flush:
if (send_buffer) {
if (just_flush) { /* if flush is called prior to proper end,
ensure
presence of NUL */
final_buffer[final_buffer_length] = '\0';
}
OG(php_body_write)(final_buffer, final_buffer_length TSRMLS_CC);
}
in flush:
if (sapi_module.flush) {
sapi_module.flush(SG(server_context));
return SUCCESS;
} else {
return FAILURE;
}
i can't understand well with this codes but i think maybe some buffer
is not zeromemory befor used.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44725&edit=1