curl_setopt

(PHP 4 >= 4.0.2, PHP 5)

curl_setopt -- Set an option for a CURL transfer

Description

bool curl_setopt ( resource ch, string option, mixed value)

The curl_setopt() function will set options for a CURL session identified by the ch parameter. The option parameter is the option you want to set, and the value is the value of the option given by the option.

The value should be a long for the following options (specified in the option parameter):

The value parameter should be a string for the following values of the option parameter:

The following options expect a file descriptor that is obtained by using the fopen() function:

例子 1. Initializing a new CURL session and fetching a webpage

<?php
// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close curl resource, and free up system resources
curl_close($ch);
?>