Manual
DIV class=reference>
XI. CURL, client URL library functions
PHP supports Libcurl (allows you to connect and communicate different servers with different protocols). , Libcurl currently supports HTTP, HTTPS, FTP, Gopher, Telnet, dict, file, and LDAP protocols. Libcurl also supports HTTPS certificate authorization, HTTP POST, HTTP PUT, FTP upload (of course you can also use PHP's FTP extension), HTTP basic form uploads, proxies, cookies, and user authentication.
In order to use the Curl function you need to install the Curl package. PHP requires you to use Curl 7.0.2-beta or later. If the version of Curl is lower than 7.0.2-beta,php will not work.
To use PHP's curl support, you must recompile PHP with the--with-curl[=dir] parameter (dir is the directory that contains the library and header files).
These functions are added in PHP 4.0.2.
Once you have compiled PHP with Curl support, you can use the Curl function. The basic idea is that you use the Curl_init () function to initialize the curl session, and then you can set all your options, execute through the curl_exec () function, and finally you can function to end your session with the Curl_close () function. Here is an example of putting a PHP home page back into a file.
Example 1. Retrieving PHP home page using PHP's Curl module
$ch = Curl_init ("http://www.php.net/");
$fp = fopen ("Php_homepage.txt", "w");
curl_setopt ($ch, Curlopt_file, $fp);
curl_setopt ($ch, Curlopt_header, 0);
Curl_exec ($ch);
Curl_close ($ch);
Fclose ($FP);
?>
Directory list
curl_init-initialization of a curl session
curl_setopt-setting an option for a curl call
Curl_exec-performing a Curl session
curl_close-closing a Curl session
curl_version-returns the current Curl version