What is Curl: cURL stands for “Client URLs”. cURL and libcurl are libraries which allow you to communicate and connect to many kind of servers with a variety of Internet protocols. Libcurl library is developed by “Daniel Stenberg”.
Following aspects a libcurl supports:
- http, ftp, gopher, telnet, dict, file, and ldap protocols.
- It supports https certificates
- http post, http put, ftp uploading
Curl is used to ‘implement payment gateways’ in various kind of payment notification scripts,login the other websites and access members only section and download and upload files from remote servers.
Curl follows the following steps:
curl_init – It is used to initializes the session and returns a cURL handle which can be passed to other cURL functions.
curl_setopt – This is the most important function of Curl library. All curl operations are performed by this function. This function is called many times and defines exactly what we want the Curl library to do.
curl_exec – It is ued to execute a cURL session.
curl_close – Closes the current cURL session.
Example: In this example a new curl session is initializing and used to fetching a web page
// Following lines are used to curl initialization $ch = curl_init();
// Set url to perform operation in it
curl_setopt($ch, CURLOPT_URL, “http://www.saitechnosys.com/”);
curl_setopt($ch, CURLOPT_HEADER, 0);
// This function is used to catch the URL and pass it to the browser
// Following function is used to close the url resources and
free up the system resources