Hello,
I have a few questions about cURL, please!
1- I want to use cURL in a loop to open a few documents. Do I have to put the two functions curl_init() and curl_close() inside the loop or I can put them outside. Notice that in each iteration of the loop a different document is opened.
Example, is the following correct:
$ch = curl_init(); //This is outside the loop
for($i=1; $i <= $filecount; $i++)
{
$path = ${'file_location_' . $i};
curl_setopt($ch, CURLOPT_URL, $path); //The handle $ch was set outside the loop.
.
.
.
curl_exec($ch);
}
curl_close($ch); //This is outside the loop
2- In the loop above if CURLOPT_CONNECTTIMEOUT was set to 5 (timeout after 5 seconds), and say in the third iteration of the loop the connection times out and it fails to connect to the site, then what would happen? Would other curl_setopt() functions and the function curl_exec() be executed or not?
3- What does the function curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5) return when the connection times out and it fails to connect to resource? Can I use the returned value to display a customized error message when the connection times out?