PHP4 User Manual: function-CURL

Source: Internet
Author: User
Tags curl http post
DIV class = reference>
XI. CURL, client URL library function
PHP supports libcurl (you can use different protocols to connect to and communicate with different servers )., 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 ftp extension), HTTP Basic form Upload, proxy, cookies, and user authentication.
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 CURL version is earlier than 7.0.2-beta, PHP will not work.
To support php curl, you must re-compile PHP with the -- with-curl [= DIR] parameter (DIR is the directory containing the library and header files ).
These functions are added in PHP 4.0.2.
Once you compile PHP with CURL support, you can use the curl function. The basic idea is: you use the curl_init () function to initialize the CURL session, and then you can set all your options to run through the curl_exec () function. Finally, you can use curl_close () function to end your session. The following is an example: put the PHP homepage back into a file.
Example 1. Use the php curl module to retrieve the PHP homepage
<? Php
$ Ch = curl_init (" /");
$ 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-initialize a CURL session
Curl_setopt-set an option for CURL calls
Curl_exec-execute a CURL session
Curl_close-close a CURL session
Curl_version-returns the current CURL version

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.