Easy Tutorial
❮ Func Array Diff Assoc Func String Strchr ❯

PHP cURL Functions


Overview

PHP supports the libcurl library created by Daniel Stenberg, which allows you to connect and communicate with various servers using various types of protocols.

libcurl currently supports protocols such as http, https, ftp, gopher, telnet, dict, file, and ldap. libcurl also supports HTTPS authentication, HTTP POST, HTTP PUT, FTP uploads (which can also be done via PHP's FTP extension), HTTP form-based uploads, proxies, cookies, and username + password authentication.

Methods to implement Get and Post requests using cURL in PHP

These functions were introduced in PHP 4.0.2.


Requirements

To use PHP's cURL functions, you need to install the » libcurl package.

PHP requires libcurl 7.0.2-beta or later. For using cURL with PHP 4.2.3, you need libcurl 7.9.0 or later. Starting from PHP 4.3.0, you need libcurl 7.9.0 or later. Starting from PHP 5.0.0, you need libcurl 7.10.5 or later.


Installation

To enable PHP's cURL support, you must compile PHP with the --with-curl[=DIR] option, where DIR is the path to the directory containing the lib and include directories. The include directory must have a folder named curl containing easy.h and curl.h. The lib directory should contain a file named libcurl.a. For PHP 4.3.0, you can configure --with-curlwrappers to make cURL use URL streams.

Note: Win32 users To use this module in a Windows environment, libeay32.dll and ssleay32.dll must be placed in a directory included in the PATH environment variable. Do not use the libcurl.dll from the cURL website.


Resource Types

This extension defines two resource types: cURL handle and cURL multi handle.


PHP cURL Functions

The following is a list of PHP cURL functions:

Function Description
curl_close() Closes a cURL session.
curl_copy_handle() Duplicates a cURL handle along with all of its options.
curl_errno() Returns the last error number.
curl_error() Returns a string containing the last error for the current session.
curl_escape() URL encodes the given string.
curl_exec() Executes a cURL session.
curl_file_create() Creates a CURLFile object.
curl_getinfo() Gets information regarding a specific transfer.
curl_init() Initializes a cURL session.
curl_multi_add_handle() Adds a normal cURL handle to a cURL multi handle.
curl_multi_close() Closes a set of cURL handles.
curl_multi_exec() Processes handles in the current cURL handle stack.
curl_multi_getcontent() Returns the content of a cURL handle if CURLOPT_RETURNTRANSFER is set.
curl_multi_info_read() Gets information about the current transfers.
curl_multi_init() Returns a new cURL multi handle.
curl_multi_remove_handle() Remove a handle from a cURL multi handle resource.
curl_multi_select() Wait for activity on any cURL multi handle connection.
curl_multi_setopt() Set an option for a cURL multi transfer.
curl_multi_strerror() Return string describing error code.
curl_pause() Pause and resume a connection.
curl_reset() Reset all options of a libcurl session handle.
curl_setopt_array() Set multiple options for a cURL session.
curl_setopt() Set an option for a cURL transfer.
curl_share_close() Close a cURL share handle.
curl_share_init() Initialize a cURL share handle.
curl_share_setopt() Set an option for a cURL share handle.
curl_strerror() Return string describing the error code.
curl_unescape() Decode URL-encoded string.
curl_version() Get cURL version information.
❮ Func Array Diff Assoc Func String Strchr ❯