|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-13 13:19 UTC] mj@php.net
[2007-10-18 17:33 UTC] foxgoblin at gmail dot com
[2007-10-18 17:38 UTC] foxgoblin at gmail dot com
[2007-11-16 14:24 UTC] jani@php.net
[2007-11-24 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 13:00:01 2025 UTC |
Description: ------------ use curl_copy_handle copy the curl handle, add in curl multi handle, curl_multi_exec return nothing. Reproduce code: --------------- <? function getMultiCUrlContent($chs){ $contents = array(); $mh = curl_multi_init(); foreach($chs as $key => $ch){ curl_multi_add_handle($mh,$ch); } do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active and $mrc == CURLM_OK) { // wait for network if (curl_multi_select($mh) != -1) { // pull in any new data, or at least handle timeouts do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } if ($mrc != CURLM_OK) { echo "[".date("Y-m-d H:i:s")."]\t[getMultiCUrlContent error]\t".$mrc."\n"; } foreach($chs as $key => $ch){ if(curl_errno($ch) == CURLE_OK){ $contents[$key]= curl_multi_getcontent($ch); } else{ echo "[".date("Y-m-d H:i:s")."]\t[get content error]\t".curl_error($ch)."\n"; } } curl_multi_close($mh); return $contents; } $chs = array(); $ch = curl_init("http://www.google.com/"); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); $chs[] = $ch; $ch = curl_copy_handle($ch); $chs[] = $ch; $contents = getMultiCUrlContent($chs); print_r($contents); ?> Expected result: ---------------- Array ( [0] => <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>... [1] => <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>... ) Actual result: -------------- Array ( [0] => <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>... [1] => )