Throws a ValueError when
option is not a valid cURL option.
Changelog
Version
Description
8.4.0
CURLOPT_DNS_USE_GLOBAL_CACHE no longer has any effect,
and enabling it on thread-safe PHP builds no longer triggers a warning.
8.0.0
curl_setopt() now throws a
ValueError if
option is not a valid cURL option.
Previously, unknown options were silently ignored, and an
E_WARNING was emitted, with false returned,
only for values less than or equal to zero.
8.0.0
handle expects a CurlHandle
instance now; previously, a resource was expected.
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);
?>
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.