|
curl_setopt
Set an option for a cURL transfer
Description
bool curl_setopt(CurlHandle $handle , int $option , mixed $value )
Parameters
-
handle
-
A cURL handle returned by
curl_init.
-
option
-
The CURLOPT_* option to set.
-
value
-
The value to be set on option .
See the description of the
CURLOPT_* constants
for details on the type of values each constant expects.
Return Values
Returns true on success or false on failure.
Examples
Example #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);
?>
Notes
Note:
Passing an array to CURLOPT_POSTFIELDS will
encode the data as multipart/form-data,
while passing a URL-encoded string will encode the data as
application/x-www-form-urlencoded.
See Also
- curl_setopt_array
- CURLFile
- CURLStringFile
|