6 years ago (2015-06-30)  Hundred Encyclopedias |   First to comment  10 
post score 0 times, average 0.0

The curl_setopt() function will set options for a CURL session.The option parameter is the setting you want, and value is the value given by this option.

The values ​​of the following options will be used as long integers (specified in the option parameter):

  • CURLOPT_INFILESIZE: When you upload a file to a remote site, this option tells PHP the size of your uploaded file.
  • CURLOPT_VERBOSE: Set this option to a non-zero value if you want CURL to report every unexpected event.
  • CURLOPT_HEADER: Set this option to a non-zero value if you want to include a header in the output.
  • CURLOPT_NOPROGRESS: Set this option to a non-zero value if you don't want PHP to display a progress bar for CURL transfers.
  • Note: PHP automatically sets this option to a non-zero value. You should change this option only for debugging purposes.
  • CURLOPT_NOBODY: Set this option to a non-zero value if you do not want to include the body part in the output.
  • CURLOPT_FAILONERROR: If you want PHP to fail (the HTTP code returns 300 or more), do not display it. Set this option to a non-zero value.The default behavior is to return a normal page, ignoring the code.
  • CURLOPT_UPLOAD: Set this option to a non-zero value if you want PHP to prepare for upload.
  • CURLOPT_POST: If you want PHP to do a regular HTTP POST, set this option to a non-zero value.This POST is an ordinary application/x-www-from-urlencoded type, mostly used by HTML forms.
  • CURLOPT_FTPLISTONLY: Set this option to a non-zero value. PHP will list the list of FTP directory names.
  • CURLOPT_FTPAPPEND: Set this option to a non-zero value. PHP will use remote files instead of overriding it.
  • CURLOPT_NETRC: Set this option to a non-zero value. PHP will look in your ~./netrc file for the username and password of the remote site you want to connect to.
  • CURLOPT_FOLLOWLOCATION: Set this option to the head of a non-zero value (like 'Location:') that the server will send as part of the HTTP header (note that this is recursive and PHP will send headers like 'Location:').
  • CURLOPT_PUT: Set this option to a non-zero value to upload a file using HTTP.To upload this file you must set the CURLOPT_INFILE and CURLOPT_INFILESIZE options.
  • CURLOPT_MUTE: Set this option to a non-zero value and PHP will be completely silent about CURL functions.
  • CURLOPT_TIMEOUT: Sets a long integer number as the maximum number of seconds to extend.
  • CURLOPT_LOW_SPEED_LIMIT: Set a long integer number to control how many bytes are transmitted.
  • CURLOPT_LOW_SPEED_TIME: set a long integer number, control how many seconds to send the number of bytes specified by CURLOPT_LOW_SPEED_LIMIT.
  • CURLOPT_RESUME_FROM: Pass a long integer parameter containing the byte offset address (the starting form you want to transfer to).
  • CURLOPT_SSLVERSION: Pass a long parameter containing the SSL version.The default PHP will be determined by its own efforts. In more security you must set it manually.
  • CURLOPT_TIMECONDITION: Pass a long parameter specifying how to handle the CURLOPT_TIMEVALUE parameter.You can set this parameter to TIMECOND_IFMODSINCE or TIMECOND_ISUNMODSINCE.This is only for HTTP.
  • CURLOPT_TIMEVALUE: Passes a number of seconds from 1970-1-1 to the present.This time will be used as the specified value by the CURLOPT_TIMEVALUE option, or used by the default TIMECOND_IFMODSINCE.

The value of the following options will be used as a string:

  • CURLOPT_URL: This is the URL you want to retrieve with PHP.You can also set this option when initializing with the curl_init() function.
  • CURLOPT_USERPWD: Pass a string of the [username]:[password] style to use PHP to connect.
  • CURLOPT_PROXYUSERPWD: Pass a string of the form [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, with X or Y being excluded.HTTP delivery also supports several intervals, separated by a comma (X-Y, N-M).
  • CURLOPT_POSTFIELDS: Pass a string that is all the data for an HTTP "POST" operation.
  • CURLOPT_REFERER: A string containing a 'referer' header in the HTTP request.
  • CURLOPT_USERAGENT: A string containing the 'user-agent' header in the HTTP request.
  • CURLOPT_FTPPORT: Pass an IP address that contains the ftp 'POST' command.This POST instruction tells the remote server to connect to the IP address we specified. This string can be an IP address, a host name, a web interface name (under UNIX), or ‘-’ (use the system default IP address).
  • CURLOPT_COOKIE: Pass a header connection that contains an HTTP cookie.
  • CURLOPT_SSLCERT: Pass a string containing a PEM format certificate.
  • CURLOPT_SSLCERTPASSWD: Pass a password that contains the necessary CURLOPT_SSLCERT certificate.
  • CURLOPT_COOKIEFILE: A string that passes the name of a file containing cookie data.This cookie file can be in Netscape format, or it can be an HTTP-style header in a heap file.
  • CURLOPT_CUSTOMREQUEST: When an HTTP request is made, a character is passed to be used by GET or HEAD.It is beneficial to perform DELETE or other operations, and more Pass a string to be used instead of GET or HEAD when doing an HTTP request. This is useful for doing or another, more obscure, HTTP request.
  • Note: Do not do this before confirming your server support command.

The following options require a file description (obtained by using the fopen() function):

  • CURLOPT_FILE: This file will be the output file that you place to send. The default is STDOUT.
  • CURLOPT_INFILE: This file is the input file you sent over.
  • CURLOPT_WRITEHEADER: This file writes the head of your output.
  • CURLOPT_STDERR: This file is written with errors instead of stderr.

This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/curl-setopt-func-parameter-introduce-2.html

Post comment


No Comment


Forget password?