My apologies, I did ask this question several times, but still did not understand the answers.
Here is my current code:
while($resultSet = mysql_fetch_array($SQL)){
$ch = curl_init($resultSet['url'] . $fullcurl);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_exec($ch);
curl_close($ch);
}
What I'm doing here takes URLs from a MySQL database ($ resultSet ['url']), adding extra variables to it, only some GET data ($ fullcurl) and just querying the pages. This will run the script running on these pages, and that all that this script has to do is run these scripts. He does not need to return any result. Just load the page long enough to run the script.
However, it currently loads each URL (currently 11) one at a time. I need to download them all at the same time. I understand that I need to use curl_multi_, but I have no idea how the cURL functions work, so I donβt know how to change my code to use curl_multi_ in a while loop.
So my questions are:
How can I change this code to download all urls at once? Please explain this and do not just give me the code. I want to know what each individual function does. Will curl_multi_exec even work in a while loop, since the while loop just sends each line in turn?
, , , , cURL . php.net, , , .
: zaf, :
$mh = curl_multi_init();
$SQL = mysql_query("SELECT url FROM urls") or die(mysql_error());
while($resultSet = mysql_fetch_array($SQL)){
$ch = curl_init($resultSet['url'] . $fullcurl);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_multi_add_handle($mh, $ch);
}
curl_multi_exec($mh);
curl_multi_close($mh);