The most important function in the Curl function library is
curl_setopt (), it can customize the HTTP request by setting the options defined by the Curl function library
How to use:
BOOL curl_setopt (int ch, string option, mixed value)
The curl_setopt () function sets options for a curl session. The option parameter is the setting that you want, and value is the one given by this choice.
The values of the following options are used as long shapes (specified in the option parameter):
curlopt_infilesize:When you upload a file to a remote site, this option tells PHP the size of your upload file.
Curlopt_verbose:If you want curl to report every unexpected thing, set this option to a value other than 0.
Curlopt_header:If you want to include a header in the output, set this option to a value other than 0.
curlopt_noprogress:If you do not have PHP display a process bar for the Curl transfer, set this option to a value other than 0.
Note: PHP automatically sets this option to a value other than 0, you should only change this option for debugging purposes.
Curlopt_nobody:If you do not want to include the body part in the output, set this option to a value other than 0.
Curlopt_failonerror:If you want PHP to not display when an error occurs (HTTP code returns greater than or equal to 300), set this option to one person and not 0 value. The default behavior is to return a normal page, ignoring the code.
Curlopt_upload:If you want PHP to prepare for uploading, set this option to a value other than 0.
Curlopt_post:If you want PHP to do a regular HTTP POST, set this option to a value other than 0. This post is an ordinary application/x-www-from-urlencoded type, most of which is used by HTML forms
curlopt_ftplistonly:Setting this option to a value other than 0, PHP lists the list of directory names for FTP.
Curlopt_ftpappend: To set this option to a value other than 0, PHP will apply the remote file instead of overwriting it.
CURLOPT_NETRC:Set this option to a value other than 0, PHP will look in your ~./netrc file for the user name and password of the remote site you want to connect to.
Code Academy PHP
curlopt_followlocation://Set this option to a header that is not a value of 0 (like ' Location: ') and the server sends it as part of the HTTP header (note that this is recursive and PHP will send the header as ' location: ').
Curlopt_put:Set this option to use HTTP to upload a file for a value other than 0. To upload this file you must set the Curlopt_infile and Curlopt_infilesize options.
Curlopt_mute://Set this option to a value other than 0, and PHP will be completely silent for the curl function.
curlopt_timeout:Sets a long shape number, as the maximum continuation of how many seconds.
curlopt_low_speed_limit://Sets a long shaping number that controls how many bytes are transferred.
Curlopt_low_speed_time:Sets a long shape number that controls how many seconds to transmit curlopt_low_speed_limit the specified number of bytes.
Curlopt_resume_from:Pass a long shaping parameter that contains the byte offset address (the start form you want to transfer to).
curlopt_sslversion:Pass a long parameter that contains the SSL version. The default PHP will be determined by its own efforts, and in more security you must set it up manually.
curlopt_timecondition://Pass a long parameter that specifies how the Curlopt_timevalue parameter is handled. You can set this parameter to Timecond_ifmodsince or timecond_isunmodsince. This is used only for HTTP.
Curlopt_timevalue:Pass a number of seconds from 1970-1-1 onwards to the present. This time will be used by the Curlopt_timevalue option as the specified value, or by default timecond_ifmodsince.
The values of the following options will be used as strings:
Curlopt_url:This is the URL address you would like to retrieve with PHP. You can also set this option when initializing with the Curl_init () function.
curlopt_userpwd://Pass a shape like [Username]:[password] style string, function PHP to connect.
curlopt_proxyuserpwd:Pass a string that is formatted as [Username]:[password] to connect to the HTTP proxy.
Curlopt_range:Pass a range that you want to specify. It should be in the ' X-y ' format, except that X or Y is excluded. HTTP delivery also supports several intervals, separated by a phrase (x-y,n-m).
curlopt_postfields://A string that passes all data as an HTTP "POST" operation.
Curlopt_referer:A string that contains a ' referer ' header in the HTTP request.
curlopt_useragent://A string that contains a ' user-agent ' header in the HTTP request.
curlopt_ftpport://Pass an IP address that contains the FTP ' POST ' command used. This post command tells the remote server to connect to the IP address we specified. This string can be an IP address, a host name, a network interface name (under Unix), or '-' (using the system default IP address).
Curlopt_cookie://Pass a header connection that contains an HTTP cookie.
Curlopt_sslcert:Pass a string containing a certificate in PEM format.
curlopt_sslcertpasswd:Pass a password that contains the required use of the Curlopt_sslcert certificate.
curlopt_cookiefile://A string that passes the name of a file that contains cookie data. This cookie file can be a Netscape format, or an HTTP-style header that is stockpiled in a file.
curlopt_customrequest:When an HTTP request is made, passing a character is used by get or head. is useful for delete or other operations
Note: Do not do this before confirming your server support commands.
The following options require a file description (obtained by using the fopen () function):
Curlopt_file:This file will be the output file where you placed the transfer, the default is stdout.
curlopt_infile://This file is the input file you sent over.
Curlopt_writeheader://This file is written with the head part of your output.
curlopt_stderr://This file is written with errors rather than stderr.