Detecting if ob_start is called from a callback function (bug #2733)
| From: | Frederic Poeydomenge | Date: | Fri, 12 Nov 2004 14:14:20 +0000 |
| Subject: | Detecting if ob_start is called from a callback function (bug #2733) | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-34359@lists.php.net to get a copy of this message | ||
Hi,
I've got a bug in the Var_Dump class (bug #2733
http://pear.php.net/bugs/bug.php?id=2733),
and I cannot find an
acceptable solution to the problem.
The Var_Dump class captures the output of the var_dump function, by
using output control functions (ob_start...), because this is the only
way to save it in a string (as stated by the doc). But the problem is
that ob_start() may not be called from a callback function, in which
case it produce a fatal error :
"Fatal error: ob_start(): Cannot use output buffering in output
buffering display handlers in /usr/share/pear/Var_Dump.php on line 162"
Putting a @ in front of ob_start does not prevent the problem, and there
is no function that can help in this situation (ob_get_level give the
nesting level, but does not tell if we are in an output buffering
display handler).
Does someone here know if there is a way to detect if ob_start is called
from a callback function, or at least how to avoid the problem ?
Or do I just need to specify in the Var_Dump doc that
"Var_Dump::toString may not be called from a callback function. If you
call it from callback function, the behavior is undefined."
(extract slightly modified from
http://www.php.net/manual/fr/function.ob-start.php)
?
Regards,
--
Frederic Poeydomenge
Web : http://fpoeydomenge.free.fr/
E-mail : fpoeydomenge@free.fr
GnuPG : http://fpoeydomenge.free.fr/public-key.asc
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]