A brief introduction to the difference between curl and Libcurl

Source: Internet
Author: User
Tags curl ftp http post imap ldap gopher

This article mainly introduces the difference of Curl and libcurl, this article explains the curl Introduction, Libcurl profile, curl and libcurl contrast, "curl" the different meaning of the use of Php curl and libcurl content, so many curl, Do not understand, read this article just know, we have been used in fact is libcurl, need friends can refer to the

Curl Introduction

Curl is an open source file Transfer tool that uses URL syntax to work on a command-line basis.

It supports many protocols: DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, Imaps, LDAP, LDAPS, POP3, Pop3s, RTMP, RTSP, SCP, SFTP, SMTP, SM TPS, Telnet and TFTP.

Curl also supports SSL certificates, HTTP POST, http put,ftp upload, HTTP upload based on form, proxy (proxies), cookies, username/password Authentication (Basic, Digest, NTLM, etc.), download file breakpoints, Upload file breakpoint Continuation (file transfer resume), HTTP proxy server pipeline (proxy tunneling), and other attributes.

Curl is the Swedish Curl organization developed, Curl's official website is http://curl.haxx.se/, can obtain its source code and the related explanation from the official website.

Libcurl Introduction

Libcurl for a free open source, client URL Transfer Library, support for Dict, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, Imaps, LDAP, LDAPS, POP3, Pop3s, RTMP, RTSP, SCP, SFTP, SMTP, Smtps, Telnet and TFTP protocols.

Like Curl, Libcurl also supports SSL certificates, HTTP POST, http put,ftp upload, HTTP upload based on form, proxy (proxies), cookies, username/password Authentication (Basic, Digest, NTLM, etc.), Download file breakpoint Continuation, upload file breakpoint continuation (file transfer resume), HTTP proxy server pipeline (proxy tunneling) and so on.

Libcurl is highly portable, can work on different platforms, support Windows,unix,linux and so on.

Libcurl is free, thread-safe, IPV6-compliant, colleague it has many other very rich features. Libcurl has been adopted by many well-known large enterprises and applications.

Here you can get Libcurl source code and related documents.

Comparison between Curl and Libcurl

Same point

Curl and Libcurl can use a variety of protocols to transfer files, including HTTP, HTTPS, FTP, FTPS, GOPHER, LDAP, DICT, TELNET and file.

Different points

Curl is a command-line tool that can run curl through a shell or a script. The library used at the bottom of the curl is libcurl.

Libcurl is a library that is commonly used with other programs, such as command-line tools curl, which encapsulates the Libcurl library. So we can also use Libcurl in your own programs or projects to get powerful features like curl. The next PHP extension to be introduced is an encapsulation of the curl.

Several nouns

The different meanings of "curl"

1.curl refers to the Curl command-line tool, which can run curl from the command line or from a script or batch file. Curl was created in 1998 and offers more than 100 options to control it.

2.cURL is the name of a software project. The software project contains the above mentioned curl and Libcurl, and is open source.

3.CURL is typically used as the name for Libcurl extensions in PHP. This extension ensures that PHP programmers have access to the functionality provided by the Libcurl library in their programs.

curl-Command line tools

1. command-line tool that you can run from a shell or from a script.

2. Provides more than 130 different "flags"

3. Behavior that is commonly used to simulate browsers

4. Cross-platform


1. Use as a development library for other programs

2. Can be combined with many languages, such as PHP, C + +

3. Cross-platform

4. offers a variety of different APIs to use it

Using Curl and Libcurl in PHP

Using Curl in PHP

Using Curl in PHP is very simple, as long as you invoke several related functions in PHP that execute system commands.

code example:

The code is as follows:

$baidu =shell_exec ("/usr/bin/curl-l http://www.baidu.com");

Var_dump ($baidu);

Using Libcurl in PHP

Use Libcurl in PHP, which is what we normally call "curl" in PHP. This section will be given in a later article, where only one sample code is written:

The code is as follows:

FTP this script to a server

$fp = fopen (__file__, "R");

$url = "ftp://username:password@mydomain.com:21/path/to/newfile.php";

$ch = Curl_init ();

curl_setopt ($ch, Curlopt_url, $url);

curl_setopt ($ch, Curlopt_returntransfer, 1);

curl_setopt ($ch, curlopt_upload, 1);

curl_setopt ($ch, Curlopt_infile, $fp);

curl_setopt ($ch, CURLOPT_FTPASCII, 1);

curl_setopt ($ch, Curlopt_infilesize, FileSize (__file__));

$result = curl_exec ($ch);

Curl_close ($ch);

Using Curl or Libcurl?

Using curl or Libcurl this needs to be based on specific circumstances. For example, we should use curl when there is a timed script that sends mail when a file on a remote server changes, or if the current PHP environment does not support Libcurl. Otherwise, we can use Libcurl.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.