AHA7 Posted May 27, 2007 Share Posted May 27, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/53148-a-few-questions-about-curl/ Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 maybe you should run some tests! edit reading the manual also helps cURL Quote Link to comment https://forums.phpfreaks.com/topic/53148-a-few-questions-about-curl/#findComment-262564 Share on other sites More sharing options...
AHA7 Posted May 27, 2007 Author Share Posted May 27, 2007 I did read the mannual, but they didn't specifically say anything about what curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, VALUE) returns when the connection times out. I have also tried to do some tests but the connection seemed to always succeed. Could not make it time out. Quote Link to comment https://forums.phpfreaks.com/topic/53148-a-few-questions-about-curl/#findComment-262567 Share on other sites More sharing options...
dj-kenpo Posted May 27, 2007 Share Posted May 27, 2007 if you want to make a page that times out, build soemthing with a loop that loops 10k times, etc... then see what happens. I believe it just returns nothing, $string=""; Quote Link to comment https://forums.phpfreaks.com/topic/53148-a-few-questions-about-curl/#findComment-262737 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.