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: 例子 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); ?>
$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);
?>