아무도 내가 왜 여기에 두 개의 루프가 있는지 이해할 수 있습니까?CURL MULTI - 왜 두 개의 루프가 필요합니까?
<?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);
?>
코드는 http://php.net/manual/en/function.curl-multi-exec.php에서 가져옵니다 - 첫 번째 예
또 다른 문제는 코드가 이상하게 multi_exec 기능이없는 컬을 사용할 때 이런 일이 없었는데 어느 화면에 모두를 출력입니다. 전에도 내용을 에코해야했지만,이 내용은 묻지도 않고 모든 것을 흐리게합니다.
bcoa 두 개의 서로 다른 'UR'L이 있으며 두 개의 서로 다른'컬 객체 '가 존재합니다. – diEcho
아니, 그 이유가 아닙니다. 멀티 인터페이스는 동일한 루프에서 동시에 많은 드라이브를 "구동"합니다. –