1

With normal curl when I went on page with normal curl it gave me the source code of one page. And I could just get it as string like this :

$ch = curl_init(); $contents = curl_exec($ch); echo $contents; // echos sourcecode of one page 

But now i have curl_multi_exec, I tried echoing it, but it gave me 0000000000000.

$mh = curl_multi_init(); curl_multi_add_handle($mh,$curls[0]); curl_multi_add_handle($mh,$curls[1]); curl_multi_add_handle($mh,$curls[2]); curl_multi_add_handle($mh,$curls[3]); curl_multi_add_handle($mh,$curls[4]); $running = null; do { usleep(10000); $sisu = curl_multi_exec($mh, $running); } while($running > 0); echo $sisu; // just echos 000000000000000 , but it should echo source of 5 pages 

What I am doing wrong?

2
  • Well, I'm not an expert, but maybe $running = null (forgot the dollar sign)? Commented May 15, 2011 at 19:42
  • @NordVind : Fixed it, was just a typo. Commented May 15, 2011 at 19:46

2 Answers 2

4

Have a look at the curl_multi_getcontent() function and the CURLOPT_RETURNTRANSFER option.

There's a nice example of using the curl_multi code here: http://www.jaisenmathai.com/articles/php-curl-asynchronous.html

Sign up to request clarification or add additional context in comments.

Comments

4

Try this after the while loop:

for($i=0;$i<5;$i++) { $resps[$i] = curl_multi_getcontent($curls[$i]); echo $resps[$i]; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.