-1

I have the following methods in my class:

public function __construct(){
    $this->handle = curl_init();
}

public function setOptArrayAndExecute(){

    $curlArray = curl_setopt_array(
            $this->handle,
            array(
                    CURLOPT_URL             => $this->getUrl(),
                    CURLOPT_USERAGENT       => $this->getUserAgent(),
                    CURLOPT_COOKIEJAR       => $this->getCookie(),
                    CURLOPT_COOKIEFILE      => $this->getCookie(),
                    CURLOPT_REFERER         => $this->getReferer(),
                    CURLOPT_TIMEOUT         => $this->getTimeOut(),
                    CURLOPT_FOLLOWLOCATION  => true
            )
    );
    ob_start(); //<-- Execution stops here
    curl_exec($this->handle);
    $this->response = ob_get_contents(); 
    curl_close($this->handle);
    ob_end_clean();
    return $this->response;
}

So I just wrote down the specific part of code instead of the whole class. I watched my php.ini: Output buffering is set 'On'. I also have error reporting activated:

error_reporting(E_ALL);
ini_set('display_errors', 1);

My PHP Version is 5.4.3. The script just stops at ob_start() without any notice or error report ... I have no clue what I missed out or what I did wrong. I really apreciate your help.

Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
user2853437
  • 750
  • 8
  • 27
  • I don't think its a problem with `ob_start`. remove `ob_start` and `ob_end_clean`, then re run your code. the object buffering is causing any errors or warning generated before `ob_end_clean();` to be suppressed. – chiliNUT Oct 19 '13 at 20:51
  • Yes. You were right. I forget 'http://' for the url. Thanks for the hint. So the buffer couldn't load I guess, nevertheless I don't understand why the code always stopped working on ob_start – user2853437 Oct 19 '13 at 21:22

1 Answers1

0

Also, you forgot to set CURLOPT_CONNECTTIMEOUT, which can cause 5 minute long connect attempts, which will hang your script.

Alex G
  • 3,048
  • 10
  • 39
  • 78