Simple Introduction to curl Common setup items

Source: Internet
Author: User

Curl Settings Item

The settings for curl are set by the curl_setopt function and are prototyped as follows:

Boolcurl_setopt (resource $ch, int $option, mixed $value);

Common setup items are described below:

1. Curlopt_referer:

Automatically set the Referer information in the header when based on location: redirection

2. Curlopt_cookiesession:
When enabled, only a session cookie is passed, ignoring other cookies, and by default, curl returns all cookies to the server side. Sessioncookie refers to a cookie that is used to determine whether a server-side session is valid.

3. Curlopt_followlocation:

Start placing the location returned by the server in the header, return it recursively to the server, and use Curlopt_maxredirs to limit the number of recursive returns.

4. Curlopt_header:

When enabled, the information for the header file is output as a traffic flow.

5. Curlopt_returntransfer:

The information obtained by CURL_EXEC () is returned as a file stream, rather than as a direct output.

6. Curlopt_infilesize:
Set the size of the upload file in bytes

7. Curlopt_maxconnects:

The maximum number of connections allowed, over which connections should be stopped by Curlopt_closepolicy.

8. Curlopt_maxredirs:

Specifies the maximum number of HTTP redirects to use with curlopt_followlocation.

9. Curlopt_cookie:

Sets the content of the cookie portion of the HTTP request. Multiple cookies are separated by semicolons, with a semicolon followed by a space.

10. Curlopt_cookiefile:

The file name that contains the cookie data, the format of the cookie file can be in Netscape format, or just plain HTTP header information is stored in the file.

One. Curlopt_cookiejar:

A file that holds cookie information after connection.

Curlopt_encoding:

The value of the accept-encoding in the HTTP request header. Supported encodings are by identity,deflate and gzip. If the string is empty, the request header sends all supported encoding types.

Curlopt_postfileds:

All data is sent using the post operation in the HTTP protocol.

Curlopt_range:

In the form of X-y, where X-y is the range of options to get data.

Curlopt_referer:
The contents of Referer: In the HTTP request header.

Curlopt_jhttpheader:

An array used to set the HTTP header field.

Curlopt_file:

Sets the location of the output file, the value is a resource type, the default is Sdout (browser)

18. Curlopt_infile:

The file address to be read when uploading the file, the value is a resource type.

Curlopt_headerfunction:

Set a callback function with two parameters, the first being a resource handle for curl, and the second is the header data for the output.

Curlopt_writefunction:
A callback function that sets two parameters, the first argument is a session handle, and the second is a string of HTTP response header information.

Note

If you feel that this function is cumbersome, you can use the curl_setopt_array function to put all of the settings as an array in the set.

Simple Introduction to curl Common setup items

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.