curl_setopt
Function • Params and return types changed in PHP 8.0
Set an option for a cURL transfer.
curl_setopt
Function synopsis
curl_setopt(
CurlHandle $handle,
int $option,
mixed $value
): bool
Parameters
$handle
TypeCurlHandle
$option
Typeint
The CURLOPT_*
option to set.
$option
accepts one of the following constant values:
CURLINFO_HEADER_OUT
CURLOPT_AUTOREFERER
CURLOPT_BINARYTRANSFER
CURLOPT_CERTINFO
CURLOPT_CONNECT_ONLY
CURLOPT_COOKIESESSION
CURLOPT_CRLF
CURLOPT_DISALLOW_USERNAME_IN_URL
CURLOPT_DNS_SHUFFLE_ADDRESSES
CURLOPT_DNS_USE_GLOBAL_CACHE
CURLOPT_FAILONERROR
CURLOPT_FILETIME
CURLOPT_FOLLOWLOCATION
CURLOPT_FORBID_REUSE
CURLOPT_FRESH_CONNECT
CURLOPT_FTPAPPEND
CURLOPT_FTPASCII
CURLOPT_FTPLISTONLY
CURLOPT_FTP_CREATE_MISSING_DIRS
CURLOPT_FTP_USE_EPRT
CURLOPT_FTP_USE_EPSV
CURLOPT_HAPROXYPROTOCOL
CURLOPT_HEADER
CURLOPT_HTTP09_ALLOWED
CURLOPT_HTTPGET
CURLOPT_HTTPPROXYTUNNEL
CURLOPT_HTTP_CONTENT_DECODING
CURLOPT_KEEP_SENDING_ON_ERROR
CURLOPT_MUTE
CURLOPT_NETRC
CURLOPT_NOBODY
CURLOPT_NOPROGRESS
CURLOPT_NOSIGNAL
CURLOPT_PATH_AS_IS
CURLOPT_PIPEWAIT
CURLOPT_POST
CURLOPT_PROXY_SSL_VERIFYPEER
CURLOPT_PUT
CURLOPT_RETURNTRANSFER
CURLOPT_SAFE_UPLOAD
CURLOPT_SASL_IR
CURLOPT_SSH_COMPRESSION
CURLOPT_SSL_ENABLE_ALPN
CURLOPT_SSL_ENABLE_NPN
CURLOPT_SSL_FALSESTART
CURLOPT_SSL_VERIFYPEER
CURLOPT_SSL_VERIFYSTATUS
CURLOPT_SUPPRESS_CONNECT_HEADERS
CURLOPT_TCP_FASTOPEN
CURLOPT_TCP_NODELAY
CURLOPT_TFTP_NO_OPTIONS
CURLOPT_TRANSFERTEXT
CURLOPT_UNRESTRICTED_AUTH
CURLOPT_UPLOAD
CURLOPT_VERBOSE
CURLOPT_BUFFERSIZE
CURLOPT_CLOSEPOLICY
CURLOPT_CONNECTTIMEOUT
CURLOPT_CONNECTTIMEOUT_MS
CURLOPT_DNS_CACHE_TIMEOUT
CURLOPT_EXPECT_100_TIMEOUT_MS
CURLOPT_FTPSSLAUTH
CURLOPT_FTP_FILEMETHOD
CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS
CURLOPT_HEADEROPT
CURLOPT_HTTPAUTH
CURLOPT_HTTP_VERSION
CURLOPT_INFILESIZE
CURLOPT_IPRESOLVE
CURLOPT_LOW_SPEED_LIMIT
CURLOPT_LOW_SPEED_TIME
CURLOPT_MAXCONNECTS
CURLOPT_MAXREDIRS
CURLOPT_MAX_RECV_SPEED_LARGE
CURLOPT_MAX_SEND_SPEED_LARGE
CURLOPT_PORT
CURLOPT_POSTREDIR
CURLOPT_PROTOCOLS
CURLOPT_PROXYAUTH
CURLOPT_PROXYPORT
CURLOPT_PROXYTYPE
CURLOPT_PROXY_SSLVERSION
CURLOPT_PROXY_SSL_OPTIONS
CURLOPT_PROXY_SSL_VERIFYHOST
CURLOPT_REDIR_PROTOCOLS
CURLOPT_RESUME_FROM
CURLOPT_SOCKS5_AUTH
CURLOPT_SSH_AUTH_TYPES
CURLOPT_SSLVERSION
CURLOPT_SSL_OPTIONS
CURLOPT_SSL_VERIFYHOST
CURLOPT_STREAM_WEIGHT
CURLOPT_TCP_KEEPALIVE
CURLOPT_TCP_KEEPIDLE
CURLOPT_TCP_KEEPINTVL
CURLOPT_TIMECONDITION
CURLOPT_TIMEOUT
CURLOPT_TIMEOUT_MS
CURLOPT_TIMEVALUE
CURLOPT_TIMEVALUE_LARGE
CURLOPT_ABSTRACT_UNIX_SOCKET
CURLOPT_CAINFO
CURLOPT_CAPATH
CURLOPT_COOKIE
CURLOPT_COOKIEFILE
CURLOPT_COOKIEJAR
CURLOPT_COOKIELIST
CURLOPT_CUSTOMREQUEST
CURLOPT_DEFAULT_PROTOCOL
CURLOPT_DNS_INTERFACE
CURLOPT_DNS_LOCAL_IP4
CURLOPT_DNS_LOCAL_IP6
CURLOPT_EGDSOCKET
CURLOPT_ENCODING
CURLOPT_FTPPORT
CURLOPT_INTERFACE
CURLOPT_KEYPASSWD
CURLOPT_KRB4LEVEL
CURLOPT_LOGIN_OPTIONS
CURLOPT_PINNEDPUBLICKEY
CURLOPT_POSTFIELDS
CURLOPT_PRE_PROXY
CURLOPT_PRIVATE
CURLOPT_PROXY
CURLOPT_PROXYUSERPWD
CURLOPT_PROXY_CAINFO
CURLOPT_PROXY_CAPATH
CURLOPT_PROXY_CRLFILE
CURLOPT_PROXY_KEYPASSWD
CURLOPT_PROXY_PINNEDPUBLICKEY
CURLOPT_PROXY_SERVICE_NAME
CURLOPT_PROXY_SSLCERT
CURLOPT_PROXY_SSLCERTTYPE
CURLOPT_PROXY_SSLKEY
CURLOPT_PROXY_SSLKEYTYPE
CURLOPT_PROXY_SSL_CIPHER_LIST
CURLOPT_PROXY_TLS13_CIPHERS
CURLOPT_PROXY_TLSAUTH_PASSWORD
CURLOPT_PROXY_TLSAUTH_TYPE
CURLOPT_PROXY_TLSAUTH_USERNAME
CURLOPT_RANDOM_FILE
CURLOPT_RANGE
CURLOPT_REFERER
CURLOPT_SERVICE_NAME
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
CURLOPT_SSH_PRIVATE_KEYFILE
CURLOPT_SSH_PUBLIC_KEYFILE
CURLOPT_SSLCERT
CURLOPT_SSLCERTPASSWD
CURLOPT_SSLCERTTYPE
CURLOPT_SSLENGINE
CURLOPT_SSLENGINE_DEFAULT
CURLOPT_SSLKEY
CURLOPT_SSLKEYPASSWD
CURLOPT_SSLKEYTYPE
CURLOPT_SSL_CIPHER_LIST
CURLOPT_TLS13_CIPHERS
CURLOPT_UNIX_SOCKET_PATH
CURLOPT_URL
CURLOPT_USERAGENT
CURLOPT_USERNAME
CURLOPT_USERPWD
CURLOPT_XOAUTH2_BEARER
CURLOPT_CONNECT_TO
CURLOPT_HTTP200ALIASES
CURLOPT_HTTPHEADER
CURLOPT_POSTQUOTE
CURLOPT_PROXYHEADER
CURLOPT_QUOTE
CURLOPT_RESOLVE
CURLOPT_HEADERFUNCTION
CURLOPT_PASSWDFUNCTION
CURLOPT_PROGRESSFUNCTION
CURLOPT_READFUNCTION
CURLOPT_WRITEFUNCTION
CURLOPT_SHARE
CURLOPT_FILE
CURLOPT_INFILE
CURLOPT_STDERR
CURLOPT_WRITEHEADER
CURLOPT_ACCEPT_ENCODING
CURLOPT_ADDRESS_SCOPE
CURLOPT_APPEND
CURLOPT_CRLFILE
CURLOPT_DIRLISTONLY
CURLOPT_DNS_SERVERS
CURLOPT_FTP_ACCOUNT
CURLOPT_FTP_ALTERNATIVE_TO_USER
CURLOPT_FTP_RESPONSE_TIMEOUT
CURLOPT_FTP_SKIP_PASV_IP
CURLOPT_FTP_SSL
CURLOPT_FTP_SSL_CCC
CURLOPT_FTP_USE_PRET
CURLOPT_HTTP_TRANSFER_DECODING
CURLOPT_IGNORE_CONTENT_LENGTH
CURLOPT_ISSUERCERT
CURLOPT_KRBLEVEL
CURLOPT_LOCALPORT
CURLOPT_LOCALPORTRANGE
CURLOPT_MAIL_FROM
CURLOPT_MAIL_RCPT
CURLOPT_MAXFILESIZE
CURLOPT_NETRC_FILE
CURLOPT_NEW_DIRECTORY_PERMS
CURLOPT_NEW_FILE_PERMS
CURLOPT_NOPROXY
CURLOPT_PASSWORD
CURLOPT_PREQUOTE
CURLOPT_PROXYPASSWORD
CURLOPT_PROXYUSERNAME
CURLOPT_PROXY_TRANSFER_MODE
CURLOPT_READDATA
CURLOPT_REQUEST_TARGET
CURLOPT_RTSP_CLIENT_CSEQ
CURLOPT_RTSP_REQUEST
CURLOPT_RTSP_SERVER_CSEQ
CURLOPT_RTSP_SESSION_ID
CURLOPT_RTSP_STREAM_URI
CURLOPT_RTSP_TRANSPORT
CURLOPT_SOCKS5_GSSAPI_NEC
CURLOPT_SOCKS5_GSSAPI_SERVICE
CURLOPT_SSH_KNOWNHOSTS
CURLOPT_SSL_SESSIONID_CACHE
CURLOPT_TFTP_BLKSIZE
CURLOPT_TRANSFER_ENCODING
CURLOPT_USE_SSL
CURLOPT_TELNETOPTIONS
CURLOPT_FNMATCH_FUNCTION
CURLOPT_WILDCARDMATCH
CURLOPT_TLSAUTH_PASSWORD
CURLOPT_TLSAUTH_TYPE
CURLOPT_TLSAUTH_USERNAME
CURLOPT_GSSAPI_DELEGATION
CURLOPT_ACCEPTTIMEOUT_MS
CURLOPT_MAIL_AUTH
CURLOPT_PREREQFUNCTION
$value
Typemixed
The value to be set on $option
.
See the description of the
CURLOPT_*
constants
for details on the type of values each constant expects.
$value
accepts one or a bitmask of the following constant values:
CURLAUTH_ANY
CURLAUTH_ANYSAFE
CURLAUTH_BASIC
CURLAUTH_BEARER
CURLAUTH_DIGEST
CURLAUTH_GSSAPI
CURLAUTH_GSSNEGOTIATE
CURLAUTH_NEGOTIATE
CURLAUTH_NTLM
CURLAUTH_NTLM_WB
CURLSSH_AUTH_AGENT
CURLSSH_AUTH_GSSAPI
CURL_SSLVERSION_DEFAULT
CURL_SSLVERSION_MAX_DEFAULT
CURL_SSLVERSION_MAX_NONE
CURL_SSLVERSION_MAX_TLSv1_0
CURL_SSLVERSION_MAX_TLSv1_1
CURL_SSLVERSION_MAX_TLSv1_2
CURL_SSLVERSION_MAX_TLSv1_3
CURL_SSLVERSION_SSLv2
CURL_SSLVERSION_SSLv3
CURL_SSLVERSION_TLSv1
CURL_SSLVERSION_TLSv1_0
CURL_SSLVERSION_TLSv1_1
CURL_SSLVERSION_TLSv1_2
CURL_SSLVERSION_TLSv1_3
CURLFTPAUTH_DEFAULT
CURLFTPAUTH_SSL
CURLFTPAUTH_TLS
CURLFTPMETHOD_MULTICWD
CURLFTPMETHOD_NOCWD
CURLFTPMETHOD_SINGLECWD
CURLFTPSSL_ALL
CURLFTPSSL_CONTROL
CURLFTPSSL_NONE
CURLFTPSSL_TRY
CURLFTP_CREATE_DIR
CURLFTP_CREATE_DIR_NONE
CURLFTP_CREATE_DIR_RETRY
CURLPROTO_ALL
CURLPROTO_DICT
CURLPROTO_FILE
CURLPROTO_FTP
CURLPROTO_FTPS
CURLPROTO_HTTPS
CURLPROTO_LDAP
CURLPROTO_LDAPS
CURLPROTO_SCP
CURLPROTO_SFTP
CURLPROTO_SMB
CURLPROTO_SMBS
CURLPROTO_TELNET
CURLPROTO_TFTP
CURLPROXY_HTTP
CURLPROXY_HTTPS
CURLPROXY_HTTP_1_0
CURLPROXY_SOCKS4
CURLPROXY_SOCKS5
CURL_HTTP_VERSION_1_0
CURL_HTTP_VERSION_1_1
CURL_HTTP_VERSION_2
CURL_HTTP_VERSION_2TLS
CURL_HTTP_VERSION_2_0
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
CURL_HTTP_VERSION_3
CURL_HTTP_VERSION_3ONLY
CURL_HTTP_VERSION_NONE
CURL_IPRESOLVE_V4
CURL_IPRESOLVE_V6
CURL_IPRESOLVE_WHATEVER
CURL_NETRC_IGNORED
CURL_NETRC_OPTIONAL
CURL_NETRC_REQUIRED
CURL_REDIR_POST_301
CURL_REDIR_POST_302
CURL_REDIR_POST_303
CURL_REDIR_POST_ALL
CURL_TIMECOND_IFMODSINCE
CURL_TIMECOND_IFUNMODSINCE
CURL_TIMECOND_LASTMOD
CURLCLOSEPOLICY_CALLBACK
CURLCLOSEPOLICY_LEAST_RECENTLY_USED
CURLCLOSEPOLICY_LEAST_TRAFFIC
CURLCLOSEPOLICY_OLDEST
CURLCLOSEPOLICY_SLOWEST
CURLHEADER_SEPARATE
CURLHEADER_UNIFIED
Return value
Typebool
Returns true
on success, false
on failure
Changes to the curl_setopt
Function
PHP 8.0
- Return type added:
bool
- Parameter name of parameter #1 changed:
$ch
to$handle
- Parameter type added for parameter #1 (
$handle
):CurlHandle
- Parameter type added for parameter #2 (
$option
):int
- Parameter type added for parameter #3 (
$value
):mixed
curl_setopt(
- $ch,
+ CurlHandle $handle,
- $option,
+ int $option,
- $value
+ mixed $value
- )
+ ): bool
curl_setopt
Function Availability
curl_setopt
Function AvailabilityPHP Version | Availability |
---|---|
PHP 8.5Future Release | Yes |
PHP 8.4Upcoming Release | Yes |
PHP 8.3Supported (Latest) | Yes |
PHP 8.2Supported | Yes |
PHP 8.1Security-Fixes Only | Yes |
PHP 8.0Unsupported | Yes |
PHP 7.4Unsupported | Yes |
PHP 7.3Unsupported | Yes |
PHP 7.2Unsupported | Yes |
PHP 7.1Unsupported | Yes |
PHP 7.0Unsupported | Yes |
PHP 5.6Unsupported | Yes |
PHP 5.5Unsupported | Yes |
PHP 5.4Unsupported | Yes |
PHP 5.3Unsupported | Yes |