title: Output buffering in PHP?
body: <p>I seem to be confused about PHP output buffering. I have code like this:</p>
  
  <pre><code>function return_json($obj) {
    ob_get_clean();
    ob_start();
    header("Content-Type: application/json");
    echo json_encode($obj);
    exit;
  }
  </code></pre>
  
  <p>But it doesn't seem to like the ob_get_clean().  I do that because some HTML might accidentally get generated before it gets to that point but I thought this was how you were meant to do it.</p>
  
  <p>What am I missing?</p>