note 22797 deleted from function.ob-start by sander

From: Date: Sun, 30 Jun 2002 16:56:33 +0000
Subject: note 22797 deleted from function.ob-start by sander
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-32440@lists.php.net to get a copy of this message
Remember that you *cannot* output anything directly from within the output_callback function. This code, for example: <?php function callback() { echo "Output buffering is over, but this also won't be displayed."; } ob_start('callback'); echo 'This will never be displayed.'; ob_end_clean(); ?> Will show no output whatsoever, as output buffering is still in place when the callback function is called. Using ob_end_flush instead of ob_end_clean doesn't appear to help. Everything you want to output from the function must be returned, not printed, like so: <?php function callback() { return 'Output buffering is over, and this will actually be displayed.'; } ob_start('callback'); echo 'This will never be displayed.'; ob_end_clean(); ?> My tests have also shown that you don't *have* to take the current output buffer as a parameter in the callback function.

« previous php.notes (#32440) next »