PHP CURL Tutorial

In this tutorial, I'll describe the some basics of using CURL and this is a very very beginner PHP CURL tutorial.  Curl was developed by Daniel Stanberg and is used to communicate with other servers having different protocols.

How to install Curl:  

Open php.ini file on your local server, search for 'curl'. You  will find something like this ";extension=php_curl.dll". Remove ";" semi colon and restart your server. Now your Curl library will be activated.

Basic Example:


$ch123 = curl_init("");
$fo = fopen("example.txt", "w");

curl_setopt($ch123, CURLOPT_FILE, $fo);
curl_setopt($ch123, CURLOPT_HEADER, 0);


curl_init() function is use to start a session to any website on a server, for example,
fopen() function will provide a write access to the file "example.txt".
curl_setopt() function sets the option to the session handle.
curl_exec() is used to execute a session to the site.
fclose() closes the file.

No comments:

Post a Comment