A brief introduction to the difference between Curl and Libcurl _php tutorial

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

A brief introduction to the difference between curl and Libcurl


This article mainly introduces the difference between Curl and libcurl, this article explains Curl Introduction, Libcurl Introduction, curl and libcurl contrast, "curl" different meanings, PHP use curl and libcurl content, so much curl, Do not understand, read the article only know, we have been using is libcurl, need friends can refer to the next

About Curl

Curl is an open source file Transfer tool that works with URL syntax in the command line mode.

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 uploads, form-based HTTP uploads, proxies (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 other features.

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

Libcurl Introduction

Libcurl is a free open source, client URL transfer library that supports 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 uploads, form-based HTTP uploads, proxies (proxies), cookies, username/password Authentication (Basic, Digest, NTLM, etc.), Download the file breakpoint continuation, upload the file breakpoint continuation (file transfer resume), HTTP proxy server pipeline (proxy tunneling) and so on.

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

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

Libcurl source code and related documentation can be obtained here.

Curl vs. Libcurl

Same point

Both 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 lets you run curl through a shell or a script. The library used by the bottom of curl is libcurl.

Libcurl is a library that is commonly used in conjunction with other programs, such as the command-line tool, curl, which encapsulates the Libcurl library. So we can also use Libcurl in your own programs or projects to get a powerful feature like curl. The PHP extension that will be introduced next is a package for curl.

A few nouns

Different meanings of "curl"

1.curl refers to the Curl command-line tool, which allows you to 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 of the Libcurl extension in PHP. This extension ensures that PHP programmers can access the functionality provided by the Libcurl library in their programs.

curl-command-line tools

1. Command-line tools, you can run the tool from a shell or script.

2. More than 130 different "flags" are available

3. Usually used to simulate the behavior of the browser

4. Cross-platform

libcurl-Library

1. The development library used as other programs

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

3. Cross-platform

4. offers a variety of different APIs to use it

Use Curl and Libcurl in PHP

Using Curl in PHP

Using Curl in PHP is as simple as calling a few 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 usually call "curl" in PHP. This section will be given in a later article, and only one example code is written here:

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 a timed script sends a message when a remote server's file changes or if the current PHP environment does not support Libcurl. Otherwise, we can use Libcurl.

http://www.bkjia.com/PHPjc/1025329.html www.bkjia.com true http://www.bkjia.com/PHPjc/1025329.html techarticle a brief introduction to the difference between curl and Libcurl this article mainly introduces the difference between Curl and libcurl, this article explains Curl Introduction, Libcurl Introduction, curl and libcurl contrast, Curl's different meanings, PHP ...

  • 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.