 |
curl_setopt (PHP 4 >= 4.0.2, PHP 5) curl_setopt -- Set an option for a cURL transfer 说明bool curl_setopt ( resource ch, int option, mixed value )
Sets an option on the given cURL session handle.
参数
chA cURL handle returned by
curl_init(). option
The CURLOPT_XXX option that you want to set
value
The value to be set on option.
value should be a bool for the
following values of the option parameter:
value should be an integer for the
following values of the option parameter:
value should be a string for the
following values of the option parameter:
value should be an array for the
following values of the option parameter:
value should be a stream resource (using
fopen(), for example) for the following values of the
option parameter:
value should be a string that is the name of a valid
callback function for the following values of the
option parameter:
返回值
如果成功则返回 TRUE,失败则返回 FALSE。
范例
例 1.
Initializing a new cURL session and fetching a web page
<?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, false);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?> |
|
|  |