/ home / customer care

Knowledgebase
You are here: Support > Knowledgebase > Programming

cURL Code Sample (PHP)

cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE and LDAP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, proxy tunneling, etc.

cURL is commonly needed for API communications between remote servers.

$site_url = 'http://example.com';
$ch = curl_init();$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $site_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
ob_start();
curl_exec($ch);
curl_close($ch);
$file_contents = ob_get_contents();
ob_end_clean();

echo $file_contents;
?>


Was this answer helpful?

Add to Favourites
Print this Article

Powered by WHMCompleteSolution


Language:
Valid XHTML 1.1 Valid CSS Powered by Apache Powered by MySQL Powered by PHP UTF8 Charset Minimium 800x600 Resolution