PHP4 User manual: Function-curl_php

Source: Internet
Author: User
Manual

DIV class=reference>
XI. CURL, client URL library functions

PHP supports Libcurl (allows you to connect and communicate different servers with different protocols). , Libcurl currently supports HTTP, HTTPS, FTP, Gopher, Telnet, dict, file, and LDAP protocols. Libcurl also supports HTTPS certificate authorization, HTTP POST, HTTP PUT, FTP upload (of course you can also use PHP's FTP extension), HTTP basic form uploads, proxies, cookies, and user authentication.

In order to use the Curl function you need to install the Curl package. PHP requires you to use Curl 7.0.2-beta or later. If the version of Curl is lower than 7.0.2-beta,php will not work.

To use PHP's curl support, you must recompile PHP with the--with-curl[=dir] parameter (dir is the directory that contains the library and header files).

These functions are added in PHP 4.0.2.

Once you have compiled PHP with Curl support, you can use the Curl function. The basic idea is that you use the Curl_init () function to initialize the curl session, and then you can set all your options, execute through the curl_exec () function, and finally you can function to end your session with the Curl_close () function. Here is an example of putting a PHP home page back into a file.
Example 1. Retrieving PHP home page using PHP's Curl module

$ch = Curl_init ("http://www.php.net/");
$fp = fopen ("Php_homepage.txt", "w");

curl_setopt ($ch, Curlopt_file, $fp);
curl_setopt ($ch, Curlopt_header, 0);

Curl_exec ($ch);
Curl_close ($ch);
Fclose ($FP);
?>


Directory list
curl_init-initialization of a curl session
curl_setopt-setting an option for a curl call
Curl_exec-performing a Curl session
curl_close-closing a Curl session
curl_version-returns the current Curl version

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