Curl introduction and curl_PHP tutorial in php

Source: Internet
Author: User
Tags gopher
Curl introduction and curl in php. CURL introduction curl is a file transfer tool that uses the URL syntax in the command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl is the same as CURL introduction

Curl is a file transfer tool that uses the URL syntax to work in the command line mode.

It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP.


Curl also supports HTTPS authentication, http post, http put, FTP upload, kerberos authentication, HTTP upload, proxy server, cookies, user name/password authentication, and resumable download of downloaded files, resumable Upload of uploaded files, and the http proxy server pipeline (proxy tunneling). it even supports IPv6 and socks5 proxy servers, and uploads files to the FTP server through the http proxy server, powerful functions.


Network ant in the Windows operating system, which can be achieved by the flash get function. To be accurate, curl supports file upload and download. Therefore, curl is a comprehensive transmission tool. However, users often call curl a download tool.

Curl in PHP

Php also has a set of functions for curl operations. these functions start with curl _. for details, refer to the php Manual.

Because it is highly efficient and does not require server-specific configuration support, it can be used in common virtual hosts. file_get_contents () is less efficient, and common failures and curl () are highly efficient, multithreading is supported, but curl extension must be enabled.

The steps to enable curl extension are as follows:
1. copy the three php_curl.dll, libeay32.dll, and ssleay32.dll files in the PHP folder to system32 (depending on the extension dll directory settings)

2. remove the semicolon from php. ini (c: WINDOWS directory) and extension = php_curl.dll;

3. restart apache or IIS.

Follow these steps to create a cURL request in PHP:

Initialization
Set variables
Execute and obtain results
Release cURL handle

// 1. initialization
$ Ch = curl_init ();
// 2. set options, including URL
Curl_setopt ($ ch, CURLOPT_URL, "http://www.nettuts.com ");
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
// 3. execute and obtain the HTML document content
$ Output = curl_exec ($ ch );
// 4. release the curl handle
Curl_close ($ ch );

Curl is a file transfer tool that uses the URL syntax to work in the command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl is the same...

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.