The value parameter should be a string
for the following values of the option parameter:
CURLOPT_URL: This is the URL that you want PHP to fetch.
You can also set this option when initializing a session
with the curl_init() function.
CURLOPT_USERPWD: Pass a string formatted in the [username]:[password]
manner, for PHP to use for the connection.
CURLOPT_PROXYUSERPWD: Pass a string formatted in the [username]:[password]
format for connection to the HTTP proxy.
CURLOPT_RANGE: Pass the specified range you want. It should
be in the "X-Y" format, where X or Y may be left
out. The HTTP transfers also support several intervals,
separated with commas as in X-Y,N-M.
CURLOPT_POSTFIELDS: Pass a string containing the full data
to post in an HTTP "POST" operation.
CURLOPT_REFERER: Pass a string containing the "referer"
header to be used in an HTTP request.
CURLOPT_USERAGENT: Pass a string containing the "user-agent"
header to be used in an HTTP request.
CURLOPT_FTPPORT: Pass a string containing the value which
will be used to get the IP address to use for the ftp "POST"
instruction. The POST instruction tells the remote server
to connect to our specified IP address. The string may be
a plain IP address, a hostname, a network interface name
(under Unix), or just a plain '-' to use the systems default
IP address.
CURLOPT_COOKIE: Pass a string containing the content of
the cookie to be set in the HTTP header.
CURLOPT_SSLCERT: Pass a string containing the filename
of PEM formatted certificate.
CURLOPT_SSLCERTPASSWD: Pass a string containing the password
required to use the CURLOPT_SSLCERT certificate.
CURLOPT_COOKIEFILE: Pass a string containing the name of
the file containing the cookie data. The cookie file can
be in Netscape format, or just plain HTTP-style headers
dumped into a file.
CURLOPT_CUSTOMREQUEST: Pass a string to be used instead
of GET or HEAD when doing an HTTP request. This is useful
for doing DELETE or other, more obscure, HTTP requests.
Valid values are things like GET, POST, and so on; i.e.
do not enter a whole HTTP request line here. For instance,
entering 'GET /index.html HTTP/1.0\r\n\r\n' would be incorrect.
Note: Don't do this without making sure your server supports
the command first.
CURLOPT_PROXY: Give the name of the HTTP proxy to tunnel
requests through.
CURLOPT_INTERFACE: Pass the name of the outgoing network
interface to use. This can be an interface name, an IP address
or a host name.
CURLOPT_KRB4LEVEL: Pass the KRB4 (Kerberos 4) security
level. Any of the following values (in order from least
to most powerful) are valid: 'clear', 'safe', 'confidential',
'private'. If the string does not match one of these, then
'private' is used. Setting this Option to NULL, will disable
KRB4 security. Currently KRB4 security only works with FTP
transactions.
CURLOPT_HTTPHEADER: Pass an array of HTTP header fields
to set.
CURLOPT_QUOTE: Pass an array of FTP commands to perform
on the server prior to the FTP request.
CURLOPT_POSTQUOTE: Pass an array of FTP commands to execute
on the server, after the FTP request has been performed.
The following options expect a file descriptor that is obtained
by using the fopen() function:
CURLOPT_FILE: The file where the output of your transfer
should be placed, the default is STDOUT.
CURLOPT_INFILE: The file where the input of your transfer
comes from.
CURLOPT_WRITEHEADER: The file to write the header part
of the output into.
CURLOPT_STDERR: The file to write errors to instead of
stderr.
Example 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);
?>