PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




curl_setopt

Name

curl_setopt — Sets an option on a cURL session..

Synopsis

bool curl_setopt(curld, option, value);
int curld: Handle of the cURL session
int option: Option to set
mixed value: Value of the option

Returns

TRUE on success; FALSE on failure

Description

Sets an option on the cURL session referred to by curld , which must be a valid cURL handle created with curl_init() . If curld is not a valid cURL handle, a warning is issued and nothing happens. If the call is successful, the option indicated by option is set to the value given by value .

All the possible options have corresponding constants, which are defined by PHP when the cURL package is available. These contants, along with the expected types for value , are described in the following list.

CURLOPT_COOKIE (string)

Sets the value of a cookie to be sent when requesting an HTTP resource.

CURLOPT_COOKIEFILE (string)

Sets the value of a filename containing one or more cookies to be sent when requesting an HTTP resource. The file can be in Netscape-standard cookie file format, or just a newline-delimited list of raw cookies as they appear in HTTP headers.

CURLOPT_CUSTOMREQUEST (string)

Sets the value of the HTTP request type to be used in the request. This is needed if you want to submit a request for an HTTP resource using a request type other than the default GET or HEAD. If you want to use PUT, however, note that you should use CURLOPT_PUT, and if you want to use POST you should use CURLOPT_POST.

CURLOPT_FAILONERROR (boolean)

Toggles PHP's behavior when an HTTP error code over 300 is received. The default action is to ignore such error codes; if this is set to a TRUE value, PHP will fail silently.

CURLOPT_FILE (file pointer)

Sets the local file to which the result of the fetch operation will be written.

CURLOPT_FOLLOWLOCATION (boolean)

Toggles "Location: " header recognition. If TRUE, the cURL session follows any and all "Location: " headers found in the HTTP response from the server; if FALSE, these headers are ignored.

CURLOPT_FTPAPPEND (boolean)

Toggles overwriting of a remote FTP file. If TRUE, appends to the remote FTP file; if FALSE, overwrites the remote file. The default value is FALSE.

CURLOPT_FTPASCII (boolean)

Toggles whether FTP transfers are executed in ASCII or binary mode. If TRUE, the transfer is ASCII; if FALSE, binary. This option is considered obsolete; use CURLOPT_TRANSFERTEXT instead.

CURLOPT_FTPLISTONLY (boolean)

Toggles how the cURL session deals with FTP directories. If FALSE, a complete 'ls -l'-style directory listing is returned when fetching an FTP directory. If TRUE, only regular, non-dotted filenames will be returned. Symbolic links, subdirectory names, and so on are ignored. The default is FALSE.

CURLOPT_FTPPORT (integer)

Sets the port to which to connect for FTP transfers.

CURLOPT_HEADER (boolean)

Toggles whether PHP includes any server header responses with the retrieved resource. If TRUE, headers are included; if FALSE, they're not included. The default is FALSE.

CURLOPT_HTTPPROXYTUNNEL (boolean)

Toggles whether non-HTTP transactions are tunnelled through an HTTP proxy (as set up with CURLOPT_PROXY, for instance). This option is only available if the cURL version is 7.3 or later and the PHP version is 4.0.4 or later. Unless you know exactly why you need to use this option, you probably don't.

CURLOPT_INFILE (file pointer)

Sets the input file for the transfer, if sending a file instead of receiving.

CURLOPT_INFILESIZE (integer)

Sets the size of the file to be sent, in bytes. If the file size is unknown, use -1 to indicate that.

CURLOPT_INTERFACE (string)

Sets the network interface to use for remote operations. You can use a UNIX-style interface name, with IP aliasing if supported: for instance, 'eth1:1'; an IP address; or a hostname. This option is only available if the cURL library version is 7.3 or later and the PHP version is 4.0.4 or later.

CURLOPT_KRB4LEVEL (string)

Instructs cURL to use Kerberos authentication, and sets the authentication level. The value must be 'clear', 'safe', 'confidential', or 'private'. If the option is set but not to one of the preceding strings, 'private' is used by default. This option is only available if the cURL library version is 7.3 or later and the PHP version is 4.0.4 or later.

CURLOPT_LOW_SPEED_LIMIT (integer)

Used with CURLOPT_LOW_SPEED_TIME. If the transfer speed falls below this value in bytes per second for longer than CURLOPT_LOW_SPEED_TIME, the transfer is aborted.

CURLOPT_LOW_SPEED_TIME (integer)

Used with CURLOPT_LOW_SPEED_LIMIT. If the transfer speed falls below the value given with the CURLOPT_LOW_SPEED_LIMIT option for longer than the number of seconds given with CURLOPT_LOW_SPEED_TIME, the transfer is aborted.

CURLOPT_MUTE (boolean)

Toggles whether PHP outputs information from the cURL library. If TRUE, PHP outputs this information; if FALSE, the information is not output.

CURLOPT_NETRC (boolean)

Toggles whether cURL searches for a file named .netrc containing a username and password for the resource being accessed. If TRUE, cURL searches for such a file; if FALSE, cURL doesn't search for the file. Please note that the cURL library will look only in the directory given in the $HOME environment variable; if you want to specify a different location, use putenv() .

CURLOPT_NOBODY (boolean)

Toggles whether PHP includes the body of the retrieved resource. If TRUE, the body is not retrieved; if FALSE, the body is retrieved.

CURLOPT_NOPROGRESS (boolean)

Toggles whether PHP displays a progress meter indicating how transfers are proceeding. If TRUE, the meter is not displayed; if FALSE, the meter is displayed. The default is TRUE.

CURLOPT_PORT (integer)

Use this port for communicating with the remote server.

CURLOPT_POST (boolean)

If TRUE, prepares the cURL session to perform an HTTP POST operation. The values to be sent can be set using CURLOPT_POSTFIELDS.

CURLOPT_POSTFIELDS (array)

If using CURLOPT_POST, you use CURLOPT_POSTFIELDS to set the values for the submitted variables. This must be an associative array, with the keys representing the names of the target form fields, and the values representing the values to submit.

CURLOPT_POSTQUOTE (array)

Sends a list of commands to be executed verbatim by an FTP server, just after the execution of the actual cURL transaction. These commands are often peculiar to the server in question. You need to ensure that the commands you're using will work with the server being accessed. See also CURLOPT_QUOTE.

CURLOPT_PROXY (string)

Sets the name of an HTTP proxy by which to access the requested resource. You can include a protocol prefix such as 'http://'; if you do so, it will be ignored. You can also include a port number suffix such as ':8080'; if you do so, this port number is used instead of the one supplied with CURLOPT_PROXYPORT.

CURLOPT_PROXYPORT (integer)

Sets the proxy port to use if none is specified in the CURLOPT_PROXY string.

CURLOPT_PROXYUSERPWD (string)

Sets the username and password for proxy authentication, if needed. The format is 'username:password'.

CURLOPT_PUT (boolean)

If true, sets the cURL session to perform an HTTP PUT operation. Information about the file to be sent is set with CURLOPT_INFILE and CURLOPT_INFILESIZE.

CURLOPT_QUOTE (array)

Sends a list of commands to be executed verbatim by an FTP server, prior to the execution of the actual cURL transaction itself. These commands are often peculiar to the server in question. You need to ensure that the commands you're using will work with the server being accessed. See also CURLOPT_POSTQUOTE.

CURLOPT_RANGE (string)

Specifies a range of the remote resource to fetch. The format of the string is 'A-B'; multiple ranges can be concatenated using commas within the same string.

CURLOPT_REFERER (string)

Sets the HTTP_REFERER string to send to a remote HTTP server. Useful for tricking scripts into thinking that your request is being submitted from a local page.

CURLOPT_RESUME_FROM (integer)

Sets the byte offset into the target file from which PHP will begin the transfer. This is useful for resuming interrupted operations.

CURLOPT_RETURNTRANSFER (boolean)

Toggles whether the fetched resource is output to a file handle (STDOUT by default) or returned by curl_exec() . If TRUE, fetched data is returned by curl_exec() and can be assigned to a variable for processing. The default is FALSE.

CURLOPT_SSLCERT (string)

Sets the filename of a file containing an SSL certificate in PEM (Privacy-Enhanced Mail) format.

CURLOPT_SSLCERTPASSWORD (string)

Sets the password needed by the cURL library to use the SSL certificate given with the CURLOPT_SSLCERT option.

CURLOPT_SSLVERSION (integer)

If PHP can't decide which version of SSL to use for cURL operations, you can set the value manually with this option. Valid values are currently 2 and 3.

CURLOPT_STDERR (file pointer)

Sets the file to which to write any error output generated by cURL.

CURLOPT_TIMEOUT (integer)

Sets the timeout for execution of cURL functions in PHP. Once this time has expired, if the operation hasn't been completed it will be aborted.

CURLOPT_TIMECONDITION (integer)

Tells PHP how to go about fetching HTTP resources. Two predefined constants are provided: TIMECOND_IFMODSINCE, which means to fetch the resource if it has been modified since the time given with the CURLOPT_TIMEVALUE option; and TIMECOND_ISUNMODSINCE, which means to fetch the resource if it hasn't been modified since the time given with the CURLOPT_TIMEVALUE option. The default is TIMECOND_IFMODSINCE.

CURLOPT_TIMEVALUE (integer)

This sets the time used by the CURLOPT_TIMECONDITION option above. It expects a UNIX timestamp.

CURLOPT_TRANSFERTEXT (boolean)

Toggles whether to execute transfers as text or binary, as appropriate to the protocol in use.

CURLOPT_UPLOAD (boolean)

If true, sets the cURL session to perform an upload operation. This would typically be used in conjunction with CURLOPT_INFILE and CURLOPT_INFILESIZE.

CURLOPT_URL (string)

Sets the URL of the remote resource to which to connect. Overrides any value given directly to curl_init() .

CURLOPT_USERAGENT (string)

Sets the User_Agent header to be sent to the remote server, where applicable.

CURLOPT_USERPWD (string)

Sets the username/password combination for access to the remote resource. The format is 'username:password'.

CURLOPT_VERBOSE (boolean)

If TRUE, PHP generates as much information as it can regarding cURL operations. If FALSE, a normal amount of information is generated. The output is sent to wherever PHP is sending its error text; for instance, the Apache error_log file. See also CURLOPT_MUTE.

CURLOPT_WRITEHEADER (file pointer)

Sets the file to which retrieved headers will be written, if CURLOPT_HEADER has been set to TRUE.



For examples of the use of curl_setopt() , see the curl_exec() function.




PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.