Bug #42200 [Com]: when ob_start meet the internal functions..
| From: | haszika80 at gmail dot com | Date: | Sun, 24 Dec 2023 22:25:20 +0000 |
| Subject: | Bug #42200 [Com]: when ob_start meet the internal functions.. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-246122@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=42200&edit=1
ID: 42200
Comment by: haszika80 at gmail dot com
Reported by: roast@php.net
Summary: when ob_start meet the internal functions..
Status: No Feedback
Type: Bug
Package: Output Control
Operating System: windows xp sp2
PHP Version: 5.2.4RC1
Block user comment: N
Private report: N
New Comment:
This is/was not a bug. The sample code had two fundamental issues:
1. as the buffer was not flushed before that line, the string returned by ob_get_contents()
('roast is a good boy') was passed to the output handler (md5) twice as the buffer was
flushed at the end of the script
2. md5 expects two parameters to which OB passed the buffer contents and an int representing the OB
context op. This int was interpreted by md5 as a bool true and hence the binary return value
The following code achieves what OP wanted:
<?php
function md5Proxy($buffer, $phase) {
return md5($buffer);
};
ob_start('md5Proxy');
echo 'roast is a good boy';
ob_end_flush();
?>
Result:
-------
e21b1aad689c47aeac5b7867c2c77afa
Previous Comments:
------------------------------------------------------------------------
[2007-08-12 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2007-08-04 14:02:05] jani@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2007-08-03 11:30:01] roast@php.net
Description:
------------
I use the functions ob_* with the internal functions to control the output,but in reality, things
always happen out of expectation.
Reproduce code:
---------------
<?php
ob_start('md5');
echo "roast is a good boy";
echo ob_get_contents();
?>
Expected result:
----------------
e21b1aad689c47aeac5b7867c2c77afa
Actual result:
--------------
A瑔��)�
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=42200&edit=1