title: PHP have cURL return HTML as function return string instead of outputing to client
body: <p>After making two cURL requests the second request I want to capture the returned HTML and pass it back to the calling function as a string. Right now it instead outputs the HTML to the client. I've messed with <code>ob_end_clean()</code> and <code>ob_get_contents()</code> without success.</p>
  
  <p>Here is what I currently have...</p>
  
  <pre><code>function stuff()
  {
   //user/pass stuff omitted.
  
   $ch = curl_init();
   curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
   curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
   curl_setopt($ch,CURLOPT_HEADER,0);
   curl_setopt($ch,CURLOPT_URL,$url);
   curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
   curl_setopt($ch,CURLOPT_COOKIEFILE,$cookies);
   curl_setopt($ch,CURLOPT_POSTFIELDS,"user=$cp_user&amp;pass=$cp_pwd");
   curl_setopt($ch,CURLOPT_TIMEOUT,100020);
  
   ob_start();
   $f = curl_exec($ch);
   $h = curl_getinfo($ch);
   $p0 = explode('cpsess',$h['url']);
   $p1 = explode('/',$p0[1]);
   ob_end_clean();
  
   /***/
   ob_start();
   curl_setopt($ch,CURLOPT_URL,$q2a.$p1[0].$q2b);
   curl_setopt($ch,CURLOPT_HEADER, 0);
   curl_exec($ch);
   $r = ob_get_contents();
   ob_end_clean();
   /***/
  
   curl_close($ch);
  
   return $r;
  }
  </code></pre>