PHP4 User Manual: Function -> CURL

zhaozj2021-02-08  219

Xi. CURL, customer URL library function

PHP supports libcurl (allowing you to use different protocols to connect and communicate different servers). Libcurl currently supports HTTP, HTTPS, FTP, GOPHER, TELNET, DICT, FILE, and LDAP protocols. LibCURL also supports HTTPS licenses, HTTP POST, HTTP PUT, FTP upload (of course you can also use PHP FTP extensions), HTTP basic form upload, proxy, cookies, and user authentication.

To use the curl function you need to install the CURL package. PHP needs you to use CURL 7.0.2-Beta or higher. If the version of the CURL is below 7.0.2-beta, PHP will not work.

To use PHP's CURL support, you must re-compile PHP with -With-curl [= DIR] parameters (Dir is a directory containing the library and header files).

These functions are new in PHP 4.0.2.

Once you compile PHP supported with CURL, you can use the curl function. Basic ideas are: You use the curl_init () function to initialize the CURL session, and you can set all your options, execute it through the curl_exec () function, and finally you can effect the curl_close () function to end your session. The following is an example: it is put it back into a file to retrieve the PHP homepage.

Example 1. Remove the PHP homepage using the CURL module of PHP

$ 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 - Initializing a CURL session

CURL_SETOPT - Set up an option for the CURL call

CURL_EXEC - Execute a CURL session

CURL_CLOSE - Close a CURL session

CURL_VERSION - Returns the current CURL version

转载请注明原文地址:https://www.9cbs.com/read-3410.html

New Post(0)