The libcurl library created by Daniel Stenberg, powered by PHP, allows you to connect and communicate with a variety of servers using various types of protocols.
libcurl currently supports http, https, ftp, gopher, telnet, dict, file and ldap protocols. libcurl also supports HTTPS authentication, HTTP POST, HTTP PUT, FTP upload (this can also be done through PHP's FTP extension), HTTP form-based upload, proxy, cookies and username + password authentication.
How to use cURL to implement Get and Post requests in PHP
These functions were introduced in PHP 4.0.2.
In order to use PHP's cURL functions, you need to install the libcurl package.
PHP requires libcurl 7.0.2-beta or higher. To use cURL with PHP 4.2.3, you need to install libcurl version 7.9.0 or higher. Starting with PHP 4.3.0 you need to install libcurl version 7.9.0 or higher. Starting with PHP 5.0.0 you need to install version 7.10.5 or higher of libcurl.
To use PHP's cURL support you must add the --with-curl[=DIR] option when compiling PHP. DIR is the directory path containing lib and include. There must be a folder named curl that contains easy.h and curl.h in the include directory. There should be a file named libcurl.a in the lib folder. For PHP 4.3.0 you can configure --with-curlwrappers to make cURL use URL streams.
Note: Win32 users should note that when using this module in a Windows environment, libeay32.dll and ssleay32.dll must be placed in the directory included in the PATH environment variable. Do not use libcurl.dll from the cURL website.
This extension defines 2 resources: cURL handles and cURL batch handles.
The following contains a list of PHP cURL functions:
function | describe |
---|---|
curl_close() | Close a cURL session. |
curl_copy_handle() | Copies a cURL handle and all its options. |
curl_errno() | Returns the last error number. |
curl_error() | Returns a string protecting the most recent error for the current session. |
curl_escape() | Returns the escaped string URL-encoded for the given string. |
curl_exec() | Execute a cURL session. |
curl_file_create() | Create a CURLFile object. |
curl_getinfo() | Get information about a cURL connection resource handle. |
curl_init() | Initialize a cURL session. |
curl_multi_add_handle() | Add a separate curl handle to the curl batch session. |
curl_multi_close() | Close a set of cURL handles. |
curl_multi_exec() | Runs a subconnection of the current cURL handle. |
curl_multi_getcontent() | If CURLOPT_RETURNTRANSFER is set, returns the text stream of the fetched output. |
curl_multi_info_read() | Get the relevant transport information of the currently parsed cURL. |
curl_multi_init() | Returns a new cURL batch handle. |
curl_multi_remove_handle() | Remove a handle resource from the curl batch handle resource. |
curl_multi_select() | Wait for active connections in all cURL batches. |
curl_multi_setopt() | Set a batch cURL transfer option. |
curl_multi_strerror() | Returns a string text describing the error code. |
curl_pause() | Pause and resume connections. |
curl_reset() | Resets all options for libcurl's session handle. |
curl_setopt_array() | Set options for cURL transfer sessions in bulk. |
curl_setopt() | Set a cURL transport option. |
curl_share_close() | Close the cURL shared handle. |
curl_share_init() | Initialize the cURL shared handle. |
curl_share_setopt() | Set cURL transport options for a shared handle. |
curl_strerror() | Returns a string description of the error code. |
curl_unescape() | Decode the URL-encoded string. |
curl_version() | Get cURL version information. |