PHP Curl Usage

Source: Internet
Author: User
When using curl in PHP, you must first open Extension=php_curl.dll in front of the php.ini; go, Curl is a built-in browser in PHP, it can imitate the user browsing information for web browsing, and so on, see an example, the code is as follows:

function Postpage ($url)

{

$response = "";

$rd =rand (1,4);

$proxy = ' http://221.214.27.253:808 ';

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 of the functions as follows:

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.