Monday, 19 December 2011

How to fetch content from URL using CURL in php

Here is the curl function to retrieve content from url using php

$url="http://www.example.com";
$crl = curl_init();
        $timeout = 5;
        curl_setopt ($crl, CURLOPT_URL,$url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        $ret = curl_exec($crl);
        curl_close($crl);
        return $ret;

No comments:

Post a Comment