Php_curl.dll extension description

Source: Internet
Author: User
Tags gopher
Php_curl.dll extension introduction and explanation, what is CURL and what functions can be implemented? & Nbsp; what is CURL & nbsp; curl is a file transfer tool that uses URL syntax to work in command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, php_curl.dll extension introduction and details
What is CURL and what functions can it implement?


What is CURL?
Curl is a file transfer tool that uses the URL syntax to work in the command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl also supports HTTPS authentication, http post, http put, FTP upload, HTTP upload, proxy server, cookies, user name/password authentication, resumable download of downloaded files, and so on, powerful functions.
Which of the following functions are commonly implemented in PHP:


1. remote acquisition and collection of content
2. implement FTP upload and download for PHP web edition
3. implement simulated login
4. interface interconnection (API) and data transmission

5. implement Cookie simulation.


2. how does PHP use the CURL function?
1. during the entire operation, the first step is to use the cur_init () function for initialization.
$ Curl = curl_init ('www .php100.com ');
2. use the curl_setopt () function to set the options.
3. execute the transaction curl_exec ($ curl );
4. close curl_close ();


3. use php curl for transmission and retrieval


$ Curl = curl_init (); // initialize a cURL object
Curl_setopt ($ curl, CURLOPT_URL, "http://www.php100.com ");
// Set the URL you want to capture
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
// Set the cURL parameter to save the result to the string or output to the screen.
$ Data = curl_exec ($ curl); // run cURL to request the webpage
Curl_close ($ curl); // closes the URL request


==============

$ User = "admin ";
$ Pass = "admin100 ";
$ CurlPost = "user = $ user & pass = $ pass ";
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/edu/login. php ");
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 0 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ curlPost );
$ Data = curl_exec ($ ch );
Curl_close ($ ch );




1. CURL simulated login process and steps
2. create a temporary file in tempnam
3. use CURL to simulate login to the PHP100 Forum

$ Cookie_file = tempnam ('./temp', 'cooker ');
$ Login_url = 'http: // bbs.php100.com/login.php ';
$ Post_fields = 'cktime = 31536000 & step = 2 & pwuser = php100-88 & PWD = 1000 ';


$ Ch = curl_init ($ login_url );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post_fields );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie_file );
Curl_exec ($ ch );
Curl_close ($ ch );




$ Url = 'http: // bbs.php100.com/userpay.php ';
$ Ch = curl_init ($ url );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookie_file );
$ Contents = curl_exec ($ ch );
Preg_match ("/

  • ????? (. *) <\/Li>/", $ contents, $ arr );
    Echo $ arr [1];
    Curl_close ($ ch );
    ?>

  • 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.