Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why the first url always return null? #30

Open
cloudstoneme opened this issue Aug 6, 2016 · 2 comments
Open

why the first url always return null? #30

cloudstoneme opened this issue Aug 6, 2016 · 2 comments

Comments

@cloudstoneme
Copy link

cloudstoneme commented Aug 6, 2016

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.

@bramley
Copy link

bramley commented Aug 12, 2016

Your code works if you add this option

curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);

So I guess it is a bug somewhere.

@jmathai
Copy link
Owner

jmathai commented Aug 12, 2016

Thanks @bramley. Looks like addUrl() sets it but addCurl() does not. I will update this unless I get a PR for it first. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants