-1

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?

1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231

1 Answers1

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