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_setopt(), then you can execute the session with 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: Example 1. Using PHP's CURL
module to fetch the example.com homepage
<?php
$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
Table of Contents
curl_close -- Close a CURL session
curl_errno -- Return the last error number
curl_error -- Return a string containing the last error
for the current session
curl_exec -- Perform a CURL session
curl_getinfo -- Get information regarding a specific transfer
curl_init -- Initialize a CURL session
curl_multi_add_handle -- Add a normal cURL handle to a cURL
multi handle
curl_multi_close -- Close a set of cURL handles
curl_multi_exec -- Run the sub-connections of the current
cURL handle
curl_multi_getcontent -- Return the content of a cURL handle
if CURLOPT_RETURNTRANSFER is set
curl_multi_info_read -- Get information about the current
transfers
curl_multi_init -- Returns a new cURL multi handle
curl_multi_remove_handle -- Remove a multi handle from a
set of cURL handles
curl_multi_select -- Get all the sockets associated with
the cURL extension, which can then be "selected"
curl_setopt -- Set an option for a CURL transfer
curl_version -- Return the current CURL version
|