note 52945 added to function.ob-get-level
| From: | php-general at lists dot php dot net | Date: | Wed, 18 May 2005 15:45:16 +0000 |
| Subject: | note 52945 added to function.ob-get-level | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89590@lists.php.net to get a copy of this message | ||
Sometimes, ob_get_level() may be off by 1 because at the start of the script, it will return 1 even
if ob_start() has never been called (and clearing the output buffer via ob_end_clean() and the like
can be done without error). As a result, the first ob_start() will have an ob_get_level() of 2, the
second will be 3, and so on.
I'm not sure if this is a PHP 5 thing or possibly because our server is set to gzip all html
documents.
Also, up until at least PHP 5.0.4 (current version), ob_get_level() will always return 0 inside a
destructor. This happens because the garbage collection for output buffers has already done before
the destructor is called. If you want to do something with the output buffer from within an object
before the script exits, using a callback function with ob_start() is the way to go.
----
Manual Page -- http://www.php.net/manual/en/function.ob-get-level.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52945
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52945&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52945&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52945&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52945&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52945&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52945&report=yes
Search -- http://master.php.net/manage/user-notes.php