note 46969 deleted from function.ob-start by cmb

From: Date: Sun, 14 Jul 2019 11:24:25 +0000
Subject: note 46969 deleted from function.ob-start by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211571@lists.php.net to get a copy of this message
Note Submitter: dev at kiwicore dot org ---- 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.

« previous php.notes (#211571) next »