curl_setopt
(PHP 4 >= 4.0.2)
curl_setopt -- Set an option for a CURL transfer
Description
bool curl_setopt ( resource ch, string option, mixed value)
The curl_setopt() function will set options for a CURL session
identified by the ch parameter. The option parameter is
the option you want to set, and the value is the value of
the option given by the option.
The value should be a long for the following options (specified
in the option parameter):
CURLOPT_INFILESIZE: When you are uploading a file to a remote
site, this option should be used to tell PHP what the expected
size of the infile will be.
CURLOPT_VERBOSE: Set this option to a non-zero value if
you want CURL to report everything that is happening.
CURLOPT_HEADER: Set this option to a non-zero value if
you want the header to be included in the output.
CURLOPT_NOPROGRESS: Set this option to a non-zero value
if you don't want PHP to display a progress meter for CURL
transfers.
Note: PHP automatically sets this option to a non-zero
parameter, this should only be changed for debugging purposes.
CURLOPT_NOBODY: Set this option to a non-zero value if you
don't want the body included with the output.
CURLOPT_FAILONERROR: Set this option to a non-zero value
if you want PHP to fail silently if the HTTP code returned
is greater than 300. The default behavior is to return the
page normally, ignoring the code.
CURLOPT_UPLOAD: Set this option to a non-zero value if
you want PHP to prepare for an upload.
CURLOPT_POST: Set this option to a non-zero value if you
want PHP to do a regular HTTP POST. This POST is a normal
application/x-www-form-urlencoded kind, most commonly used
by HTML forms.
CURLOPT_FTPLISTONLY: Set this option to a non-zero value
and PHP will just list the names of an FTP directory.
CURLOPT_FTPAPPEND: Set this option to a non-zero value
and PHP will append to the remote file instead of overwriting
it.
CURLOPT_NETRC: Set this option to a non-zero value and
PHP will scan your ~./netrc file to find your username and
password for the remote site that you're establishing a
connection with.
CURLOPT_FOLLOWLOCATION: Set this option to a non-zero value
to follow any "Location: " header that the server
sends as a part of the HTTP header (note this is recursive,
PHP will follow as many "Location: " headers that
it is sent.)
CURLOPT_PUT: Set this option to a non-zero value to HTTP
PUT a file. The file to PUT must be set with the CURLOPT_INFILE
and CURLOPT_INFILESIZE.
CURLOPT_MUTE: Set this option to a non-zero value and PHP
will be completely silent with regards to the CURL functions.
CURLOPT_TIMEOUT: Pass a long as a parameter that contains
the maximum time, in seconds, that you'll allow the CURL
functions to take.
CURLOPT_LOW_SPEED_LIMIT: Pass a long as a parameter that
contains the transfer speed in bytes per second that the
transfer should be below during CURLOPT_LOW_SPEED_TIME seconds
for PHP to consider too slow and abort.
CURLOPT_LOW_SPEED_TIME: Pass a long as a parameter that
contains the time in seconds that the transfer should be
below the CURLOPT_LOW_SPEED_LIMIT for PHP to consider it
too slow and abort.
CURLOPT_RESUME_FROM: Pass a long as a parameter that contains
the offset, in bytes, that you want the transfer to start
from.
CURLOPT_CAINFO: Pass a filename of a file holding one or
more certificates to verify the peer with. This only makes
sense when used in combination with the CURLOPT_SSL_VERIFYPEER
option.
CURLOPT_SSL_VERIFYPEER: Pass a long that is set to a zero
value to stop curl from verifying the peer's certificate
(curl 7.10 starting setting this option to TRUE by default).
Alternate certificates to verify against can be specified
with the CURLOPT_CAINFO option (added in curl 7.9.8) or
a certificate directory can be specified with the CURLOPT_CAPATH
option. As of curl 7.10, curl installs a default bundle.
CURLOPT_SSL_VERIFYHOST may also need to be set to 1 or 0
if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2).
CURLOPT_SSLVERSION: Pass a long as a parameter that contains
the SSL version (2 or 3) to use. By default PHP will try
and determine this by itself, although, in some cases you
must set this manually.
CURLOPT_SSL_VERIFYHOST: Pass a long if CURL should verify
the Common name of the peer certificate in the SSL handshake.
A value of 1 denotes that we should check for the existence
of the common name, a value of 2 denotes that we should
make sure it matches the provided hostname.
CURLOPT_TIMECONDITION: Pass a long as a parameter that
defines how the CURLOPT_TIMEVALUE is treated. You can set
this parameter to TIMECOND_IFMODSINCE or TIMECOND_ISUNMODSINCE.
This is a HTTP-only feature.
CURLOPT_TIMEVALUE: Pass a long as a parameter that is the
time in seconds since January 1st, 1970. The time will be
used as specified by the CURLOPT_TIMECONDITION option, or
by default the TIMECOND_IFMODSINCE will be used.
CURLOPT_RETURNTRANSFER: Pass a non-zero value if you want
CURL to directly return the transfer instead of printing
it out directly.