English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The libcurl library supported by PHP allows you to connect and communicate with various 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 (which can also be completed through PHP's FTP extension), HTTP form-based upload, proxy, cookies, and username+password authentication.
Methods to implement Get and Post requests using CURL in PHP
These functions are in PHP 4.0.2are introduced.
To use PHP's CURL functions, you need to install » libcurlpackage.
PHP needs to use libcurl 7.0.2-beta or a higher version. In PHP 4.2.3 to use CURL, you need to install7.9.0 or a higher version of libcurl. From PHP 4.3.0 and you need to install7.9.0 or a higher version of libcurl. From PHP 5.0.0 and you need to install7.10.5or a higher version of libcurl.
To use PHP's CURL support, you must add--with-curl[=DIR] option, DIR is the directory path containing lib and include. There must be a folder named curl in the include directory, which includes easy.h and curl.h. There should be a file named libcurl.a in the lib folder. For PHP 4.3.0 you can configure--with-curlwrappers make CURL use URL streams.
Note: Win32User's attention
To use this module in Windows environment, libeay32.dll and ssleay32.dll must be placed in the directory included in the PATH environment variable. Do not use the libcurl.dll from the CURL website.
This extension defines2Resource: CURL handle and CURL batch handle.
The following includes the list of PHP CURL functions:
Function | Description |
---|---|
curl_close() | Close a CURL session. |
curl_copy_handle() | Duplicate a CURL handle and all its options. |
curl_errno() | Return the last error number. |
curl_error() | Return a string that protects the last error of the current session. |
curl_escape() | Return the escaped string, URL encoding the given string. |
curl_exec() | Execute a CURL session. |
curl_file_create() | Create a CURLFile object. |
curl_getinfo() | Get information about the 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 group of CURL handles. |
curl_multi_exec() | Run the sub-connection of the current CURL handle. |
curl_multi_getcontent() | If CURLOPT_RETURNTRANSFER is set, return the obtained output text stream. |
curl_multi_info_read() | Get the current parsing CURL related transfer information. |
curl_multi_init() | Return a new CURL batch handle. |
curl_multi_remove_handle() | Remove a handle resource from the curl batch handle resource. |
curl_multi_select() | Wait for all active connections in the CURL batch. |
curl_multi_setopt() | Set a batch CURL transfer option. |
curl_multi_strerror() | Return the string text describing the error code. |
curl_pause() | Pause and resume the connection. |
curl_reset() | Reset all options of the libcurl session handle. |
curl_setopt_array() | Set options in bulk for a CURL transfer session. |
curl_setopt() | Set a CURL transfer option. |
curl_share_close() | Close the CURL shared handle. |
curl_share_init() | Initialize a CURL shared handle. |
curl_share_setopt() | Set a shared handle CURL transfer option. |
curl_strerror() | Return the string description of the error code. |
curl_unescape() | Decode the string after URL encoding. |
curl_version() | Get CURL version information. |