Php curl\u multi\u info\u read curl\u getinfo。警告:提供的参数不是有效的卷曲句柄资源

Php curl\u multi\u info\u read curl\u getinfo。警告:提供的参数不是有效的卷曲句柄资源,php,curl,warnings,handle,curl-multi,Php,Curl,Warnings,Handle,Curl Multi,我的部分代码: do{ curl_multi_exec($mh, $running); $done = curl_multi_info_read($mh); $info = curl_getinfo($done['handle']); while($running > 0); 此代码导致警告警告:curl\u getinfo():提供的参数不是有效的curl句柄资源,我不明白为什么。当我做var_dump($done['handle'])它返回(curl)类型的


我的部分代码:

do{
    curl_multi_exec($mh, $running);
    $done = curl_multi_info_read($mh);
    $info = curl_getinfo($done['handle']);
 while($running > 0);
此代码导致警告
警告:curl\u getinfo():提供的参数不是有效的curl句柄资源,我不明白为什么。当我做
var_dump($done['handle'])它返回(curl)类型的
资源(7)
。请帮助我查找错误。

要正确使用,请使用以下PHP示例:

<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://lxr.php.net/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

?>

要正确使用,请使用以下PHP示例:

<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://lxr.php.net/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

?>


我认为你应该看看……的好例子。。您的代码有重大错误…谢谢!)你是对的。第一个例子解决了我的问题。我认为你应该看看好的例子。。您的代码有重大错误…谢谢!)你是对的。第一个例子解决了我的问题。