note 126558 added to function.ob-start
| From: | phpREMOVETHISatkennel17dotcodotuk at main dot php dot net | Date: | Fri, 05 Nov 2021 12:10:49 +0000 |
| Subject: | note 126558 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217142@lists.php.net to get a copy of this message | ||
Be very careful when returning false from your callback function!
Despite what the documentation says, this is *not* the same as returning the supplied $buffer value,
unmodified. In the context of a 'clean' operation (e.g. ob_clean()) this will result in
your callback function being disabled and skipped for any subsequent output.
The answer is to ensure you always return a string value from your callback. This is likely a bug,
and it may get fixed at some point, but it applies to all versions since PHP 5.4 up to the current
version (8.1 at time of writing). Note that it was not an issue on PHP 5.3 and below.
Some more detail can be seen on this Stack Overflow question: https://stackoverflow.com/questions/69845122/
A demonstration of the issue has been set up in this fiddle: https://3v4l.org/66cai
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 212.69.47.82)
----
Manual Page -- https://php.net/manual/en/function.ob-start.php
Edit -- https://main.php.net/note/edit/126558
Del: integrated -- https://main.php.net/note/delete/126558/integrated
Del: useless -- https://main.php.net/note/delete/126558/useless
Del: bad code -- https://main.php.net/note/delete/126558/bad+code
Del: spam -- https://main.php.net/note/delete/126558/spam
Del: non-english -- https://main.php.net/note/delete/126558/non-english
Del: in docs -- https://main.php.net/note/delete/126558/in+docs
Del: other reasons-- https://main.php.net/note/delete/126558
Reject -- https://main.php.net/note/reject/126558
Search -- https://main.php.net/manage/user-notes.php