Is there a way to check if output is buffered in php? Using ob_start() causes out buffering. Is there a way to check if that is active?
Asked
Active
Viewed 210 times
-1
-
Does `ob_get_status()` do what you want? – Barmar Aug 20 '20 at 21:48
-
I simply looked at the list of all output buffering functions, and that one stood out as the likely solution. What do you do to research this before posting? – Barmar Aug 20 '20 at 21:48
-
@Barmar the docs are confusing. I don’t see a buffers active property – 1.21 gigawatts Aug 20 '20 at 21:52
1 Answers
1
Use ob_get_status()
. If output buffering is in effect it returns an associative array containing the status of buffering. If output buffering is not in effect, it returns an empty array.
If you just want to know if buffering is enabled, you can use it as a boolean:
if (ob_get_status()) {
// do something
}

Barmar
- 741,623
- 53
- 500
- 612