|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33974 ob_list_handlers(): object-based handlers returned incorrectly.
Submitted: 2005-08-03 12:35 UTC Modified: 2005-08-04 13:58 UTC
From: php at koterov dot ru Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.11 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: php at koterov dot ru
New email:
PHP Version: OS:


 [2005-08-03 12:35 UTC] php at koterov dot ru
Seems ob_list_handlers() cannot return handlers represented as object with method names (see ob_start(array(&$obj, 'F'))). It returns them as "ClassName::MethodName", not as array(..., ...).

Reproduce code:
class C { function F($s) { return $s; } }
$obj = new C();
ob_start(array(&$obj, 'F'));
$list = ob_list_handlers();

Expected result:
array(1) { [0]=>  array(..., 'F') }
// where "..." is object $obj

Actual result:
array(1) { [0]=>  string(4) "c::F" }


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-03 13:22 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2005-08-03 15:35 UTC] php at koterov dot ru
There is nothing said about this behaviour in the documentation:

And - if I cannot trust the result of ob_list_handlers() (I cannot - it returns bogus handler names), is this function necessary at all?
 [2005-08-03 15:46 UTC]
This is how the engine stores callbacks names.
ob_list_handlers() has nothing to do with it. 
This functions is for debugging purposes only and there is nothing said in the docs that it should return valid callbacks.
 [2005-08-04 13:49 UTC] php at koterov dot ru
Very strange, because object-based callbacks works fine with ob_start(). So I guess that full callback info is stored somewhere.

OK, debug purpose. But - maybe write it explicitly in documentation? "This function is for debug purposes only. Do not try to use it for manual callback execution - references will be wrong for object-based callbacks."
 [2005-08-04 13:58 UTC] php at koterov dot ru
I'll detalize why do I say all this words. It would be great  to MANUALLY process all output buffers with their callbacks at the end of script - something like this:

foreach (array_reverse(ob_list_handlers()) as $h) {
  $text = ob_get_contents(); ob_end_clean();
  echo call_user_func($h, $text);

Why? Very simple: if I let the callbacks to be called automatically, I'll loose ALL errors, warnings and notices in them, because errors are suppress on standard OB callback execution. But, if I call all the callbacks manually (see example above), it's OK with errors.

I use OB callbacks very often, an there are a lot of PHP code in them (e.g. - HTML tag parsing, placeholder substitutions etc.). Callbacks is a very powerful technique, but - almost undebuggable.

Maybe extend ob_get_status(true) adding valid callback references to returned array?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 21:01:28 2024 UTC