note 46969 added to function.ob-start
| From: | dev at kiwicore dot org | Date: | Thu, 28 Oct 2004 20:49:58 +0000 |
| Subject: | note 46969 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79292@lists.php.net to get a copy of this message | ||
I wanted to do things a very particular way with output buffering and shutdown functions; using
register_shutdown_function instead of the built in callback feature of this function. However, one
should note that this won't work, because the contents of the buffer are no longer in scope
when PHP is calling the shutdown functions. This would have been easy to see EXCEPT that PHP
graciously flushes any unsent buffers at the end of the script, or when calling exit. So:
<?php
ob_start();
echo 'hi';
exit;
?>
Prints "hi". In a nutshell, if you want it to have a shutdown function that handles an
output buffer, just specify it in ob_start() and let PHP automatically call it at the end of the
script.
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46969
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46969&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46969&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46969&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46969&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46969&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46969&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46969&report=yes
Search -- http://master.php.net/manage/user-notes.php