title: Are there pitfalls to using output buffering in functions that shouldn't have output?
body: <p>Sometimes we have functions which aren't intended to print (ie. output) anything. However, if some code within them throws an error, this will sometimes be output. That'll mean that this error shows up in our final HTML at whatever point the function was run. To avoid this, it occurs to me that it might be a good idea to put <code>ob_start();</code> at the start of the function, and <code>ob_end();</code> at the end (or before the <code>return</code> statement).</p>
  <p>Is this a bad idea? Is it good practice? Are there pitfalls? Should I use <code>ob_end_clean()</code> instead?</p>
  <p>How nested output buffering works seems relevant, but I don't understand this. It just occurs to me that my function might be called when another function has run <code>ob_start();</code> but not yet run <code>ob_end();</code>.</p>
  <p>An example might be in WordPress or Drupal.</p>