php-multi-curl
php-multi-curl copied to clipboard
why the first url always return null?
Example Code:
$urls = array('http://google.com', 'https://twitter.com');
$mc = JMathai\PhpMultiCurl\MultiCurl::getInstance();
$calls = array();
foreach($urls as $url) {
$handle = curl_init($url);
curl_setopt( $handle, CURLOPT_NOBODY, true );
curl_setopt( $handle, CURLOPT_HEADER, false );
$calls[] = $mc->addCurl($handle);
}
$r = array();
foreach($calls as $email => $call) {
$r[] = $call->code;
}
var_dump($r);
Hi,
the result of first url will always return null, why? did I missing anything or is it a bug?
Thanks.
Your code works if you add this option
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
So I guess it is a bug somewhere.
Thanks @bramley. Looks like addUrl()
sets it but addCurl()
does not. I will update this unless I get a PR for it first. 👍