abhishekphp6 Posted March 13, 2010 Share Posted March 13, 2010 I am using the following function to get the contents of a URL function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1000); $data = curl_exec($ch); curl_close($ch); return $data; } However the problem is that if the request times out, the function doesn't return an error. If I call the same URL in browser, I can see error message ... but the function call to get_data returns nothing if the call times out. Link to comment https://forums.phpfreaks.com/topic/195108-getting-url-content-using-perl/ Share on other sites More sharing options...
abhishekphp6 Posted March 13, 2010 Author Share Posted March 13, 2010 Sorry I meant to say PHP not Perl. Link to comment https://forums.phpfreaks.com/topic/195108-getting-url-content-using-perl/#findComment-1025587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.