Phpcurl usage-PHP source code

Source: Internet
Author: User
Ec (2); when using curl in the php tutorial, you must first. enable extensionphp_curl.dll in ini. If yes, curl is a built-in browser in php. It can imitate user browsing information for website browsing. Let's look at the following example. Functionpostpage ($ url) {$ response & quot; $ rdrand (1, 4); $ proxyhtt script ec (2); script

When using curl in php tutorial, you must first go to php. enable extension = php_curl.dll in ini. If yes, curl is a built-in browser in php. It can imitate user browsing information for website browsing. Let's look at the following example.


Function postpage ($ url)
{
$ Response = "";
$ Rd = rand (1, 4 );
$ Proxy = 'HTTP: // 221.214.27.253: 8080 ';
If ($ rd = 2) $ proxy = 'HTTP: // 222.77.14.56: 8088 ';
If ($ rd = 3) $ proxy = 'HTTP: // 202.98.123.126: 8080 ';
If ($ rd = 4) $ proxy = 'HTTP: // 60.14.97.38: 8080 ';
If ($ url! = ""){
$ Ch = curl_init ($ url );
Curl_setopt ($ ch, curlopt_header, 0 );
Curl_setopt ($ ch, curlopt_returntransfer, true );
Curl_setopt ($ ch, curlopt_proxy, $ proxy );
$ Response = curl_exec ($ ch );
If (curl_errno ($ ch) $ response = "";
Curl_close ($ ch );
}
Return $ response;
}

Curl includes some functions

Curl_close-close a curl session
Curl_copy_handle-copy a curl handle along with all of its preferences
Curl_errno-return the last error number
Curl_error-return a string containing the last error for the current session
Curl_exec-perform a curl session
Curl_getinfo-get information regarding a specific transfer
Curl_init-initialize a curl session
Curl_multi_add_handle-add a normal curl handle to a curl multi handle
Curl_multi_close-close a set of curl handles
Curl_multi_exec-run the sub-connections of the current curl handle
Curl_multi_getcontent-return the content of a curl handle if curlopt_returntransfer is set
Curl_multi_info_read-get information about the current transfers
Curl_multi_init-returns a new curl multi handle
Curl_multi_remove_handle-remove a multi handle from a set of curl handles
Curl_multi_select-wait for activity on any curl_multi connection
Curl_setopt_array-set multiple options for a curl transfer
Curl_setopt-set an option for a curl transfer
Curl_version-gets curl version information

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.