curl_setopt
(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)
curl_setopt — Set an option for a cURL transfer
Description
Sets an option on the given cURL session handle.
Parameters
handleA cURL handle returned by curl_init().
optionThe
CURLOPT_*option to set.valueThe value to be set on
option. See the description of theCURLOPT_*constants for details on the type of values each constant expects.
Changelog
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);
?>Notes
Note:
Passing an array to
CURLOPT_POSTFIELDSwill 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() - Set multiple options for a cURL transfer
- CURLFile
- CURLStringFile
↑ and ↓ to navigate • Enter to select • Esc to close • / to open