Explanation of curl-related functions in PHP

Source: Internet
Author: User
The curl-related function documentation in PHP is free to download. abstract: curl-related functions in PHP are described in curl-related functions in PHP. in PHP, you can call the following functions to use the powerful functions provided by curl. Curl_init-initialize a curl dialog and return a linked resource handle curl_exec- Explanation of curl-related functions in PHP

Explanation of curl-related functions in PHP


In PHP, you can call the following functions to use the powerful functions provided by curl.

Curl_init-initializes a curl dialog and returns a linked resource handle.

Curl_exec-run a curl dialog. if the dialog succeeds, true is returned. otherwise, false is returned. If CURLOPT_RETURNTRANSFER is set, the response content is returned successfully. otherwise, false is returned.

Curl_close-close a dialog and release resources

Curl_getinfo-get a curl connection resource handle message

Curl_copy_handle-copy a curl to connect all content and parameters of the resource
Curl_errno-returns a number containing the current dialog error message.
Curl_error-returns a char string containing the current dialog error message.

Curl_multi_add_handle-add a separate curl handle resource to the curl batch processing dialog box

Curl_multi_init-initialize a curl batch processing handle resource

Curl_multi_exec-parses a curl batch handle

Curl_multi_close-close a batch processing handle resource and release the resource
Curl_multi_getcontent-return the obtained output document stream
Curl_multi_info_read-get the transmission message of the currently resolved curl
Curl_multi_rearouse_handle-remove a handle resource from the curl batch processing handle.
Curl_multi_select-Get all the sockets associated with the cURL extension, which can then be "selected"
Curl_setopt_array-set the dialog parameters for a curl in the form of an array
Curl_setopt-set the dialog parameter for a curl
Curl_version-Get version messages related to curl



Example of related functions:

The curl_init () function initializes a curl dialog. a parameter of the curl_init () parameter is optional, indicating a url address.
The function of the curl_exec () parameter is to run a curl dialog, and a parameter is the handle returned by the curl_init () parameter.
The curl_close () parameter is used to close a curl dialog, and a parameter is the handle returned by the curl_init () parameter.

$ Ch = curl_init ("#");
Curl_exec ($ ch );
Curl_close ($ ch );
?>



The function of the curl_version () parameter is to obtain the version message related to curl. the curl_version () parameter has a parameter and it is unclear what it is.
------------------------------


Print_r (curl_version ())
?>

-----------------------------

The curl_getinfo () parameter is used to obtain a curl connection resource handle message. the curl_getinfo () parameter has two parameters. The first parameter is the resource handle of curl, the second parameter is the following constants:

------------------------------

$ Ch = curl_init ("#");
Print_r (curl_getinfo ($ ch ));
? &

Gt;

-------------------------------------

Optional constants include:
* CURLINFO_EFFECTIVE_URL: the last valid url address.
* CURLINFO_HTTP_CODE: The last received HTTP source code.
* CURLINFO_FILETIME: the time when the document is obtained remotely. if the document cannot be obtained, "-1" is returned"
* CURLINFO_TOTAL_TIME: the time consumed by the last transmission.
* CURLINFO_NAMELOOKUP_TIME: name resolution consumed

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.