Thread: cURL
View Single Post
Old 10-24-2007, 10:32 PM   #10 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I've modified it only slightly, but this works perfectly for me:

PHP Code:
function file_get_content$url )
{
    for(
$i 1$i <= 3$i++)
    {
        
$ch curl_init($url);

        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
        
$file curl_exec($ch);//Returns file contents string, FALSE on failure
        
        
curl_close($ch);

        if(
$file)
        {
            return array( 
=> TRUE=> $file );
            break;
        }
    }
    
    return array( 
=> FALSE=> '' );
}  

var_dump(file_get_content('http://www.wiredflame.com/')); 
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote