Best Jquery ,javascript, HTML5 CSS3 tutorial with jquery examples, php script , demos for beginners, web designers and web developers.

Jquery

Jquery Training

Jquery training blog

What is cURL and how to download via curl

cURL PHP/cURL is a library that helps you to make HTTP requests in PHP using libcurl. PHP supports libcurl, a library created by Daniel Stenberg. In order to use this functions you need to install the  libcurl To understand we will have to know about following terms cURL libcurl PHP/cURL cURL is a command line tool for receiving or Continue Reading


cURL

PHP/cURL is a library that helps you to make HTTP requests in PHP using libcurl.

PHP supports libcurl, a library created by Daniel Stenberg.

In order to use this functions you need to install the  libcurl

To understand we will have to know about following terms

  1. cURL
  2. libcurl
  3. PHP/cURL

cURL is a command line tool for receiving or sending files using URL syntax

libcurl  is a library that allows us to connect and communicate to different types of servers with different types of protocols.

It  is supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols.sit i also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies.

It  helps the PHP programms to make use of libcurl to make HTTP request .

Now you have an idea of the different terms used.

Basically the following steps are need to follow to use in php.

Initialize->set options->fatch/send->close

  1. Initialize a session
  2. Set options for the session
  3. Execute the action or get/send data from/to server
  4. Close the session

Example: To fetch the abc.com homepage
<?php

    1. Initialize a curl session

 

$ch = curl_init(“http://www.abc.com/”);

    1. setting options

 

$fp = fopen(“abc.txt”, “w”); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0);

    1. Execute

 

curl_exec($ch);

    1. Close

 

curl_close($ch); fclose($fp); ?>

We can do more task with curl like curl_error() , curl_setopt(), curl_getinfo(), curl_version() etc.

  1. curl_error(): to check the errors based on the return value(bool) of the curl_exec().
  2. curl_setopt() : Set an option for a transfer.
  3. curl_getinfo() :  Get information regarding a specific transfer
  4. curl_version() : Gets version information

There are lots of options are available. You can take a look at the manual for more and detailed information.

Thank you for reading this article,

If any thing is wrong in the article please do let us know in the comment section.
We will be very happy to hear that.

Please follow and like us:






About the author

Joydeb Choudhury holds a Master's degree in Computer Application from I.G.N.O.U. After working as a web developer in various companies he has started bloging in 2016.

Recent Posts of blog

Downalod Free Php Scripts