CURL, Client URL Library FunctionsCURL
&reftitle.intro;
PHP supports libcurl, a library created by Daniel Stenberg, that
allows you to connect and communicate to many different types of
servers with many different types of protocols. libcurl currently
supports the http, https, ftp, gopher, telnet, dict, file, and
ldap protocols. libcurl also supports HTTPS certificates, HTTP
POST, HTTP PUT, FTP uploading (this can also be done with PHP's
ftp extension), HTTP form based upload, proxies, cookies, and
user+password authentication.
These functions have been added in PHP 4.0.2.
&reftitle.required;
In order to use the CURL functions you need to install the CURL package. PHP requires that you use
CURL 7.0.2-beta or higher. PHP will not work with any version of
CURL below version 7.0.2-beta. From PHP version 4.2.3 you will atleast
need CURL version 7.9.0 or higher.
&reftitle.install;
To use PHP's CURL support you must also compile PHP where DIR is the
location of the directory containing the lib and include
directories. In the "include" directory there should be a folder
named "curl" which should contain the easy.h and curl.h files.
There should be a file named "libcurl.a" located in the "lib"
directory.
&reference.curl.constants;
&reftitle.examples;
Once you've compiled PHP with CURL support, you can begin using
the curl functions. The basic idea behind the CURL functions is
that you initialize a CURL session using the
curl_init, then you can set all your
options for the transfer via the curl_exec
and then you finish off your session using the
curl_close. Here is an example that uses
the CURL functions to fetch the example.com homepage into a file:
Using PHP's CURL module to fetch the example.com homepage
]]>
&reference.curl.functions;