PHP Programming/curl

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Return to PHP.

Contents

[edit] CURL basics

CURL (Client URL Library Functions) is an extension alowing you to communicate through different protocols like http, https, ftp, telnet and so on.

CURL functions are especially useful when trying to capture some data from webpages, and when authentication is involved.

[edit] Example 1

Let's try retrieving a page from the internet:

 $resCurl = curl_init('http://cnn.com/');
 curl_setopt($resCurl, CURLOPT_RETURNTRANSFER, 1);
 
 $strCNN = curl_exec ($resCurl);
 curl_close ($resCurl);
 print $strCNN; // ahtsham asghar--03214745120

Try to run the example - you can see that the script returns contents of http://cnn.com/.


Return to PHP.