Until recently, to do a web thief program to find that File_get_content has been completely unable to meet the demand. I think, in reading remote content, file_get_content in addition to use than curl convenient, other than curl good.
Main differences:
Learn to find that Curl supports many protocols, with FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, file, and LDAP, which means that it can do a lot of things file_get_content can't do. Curl in PHP can achieve remote acquisition and collection of content, PHP Web version of FTP upload download, the implementation of analog landing, interface docking (API), data transmission, implementation of analog cookies, download file breakpoints, etc., the function is very powerful.
Understand curl Some basic use, only to find that it is not difficult, just remember some of the setting parameters, difficult to get a little, but we remember a few commonly used on it.
Open Curl:
Because PHP is not supported by default Curl function, so if you want to use curl, first need to open the function in the php.ini, that is, remove; extension= php_curl.dll before the semicolon, and then save to restart the Apache/iis is good.
Basic syntax:
Copy Code code as follows:
$my _curl = Curl_init (); Initializes a Curl object
curl_setopt ($my _curl, Curlopt_url, "http://www.jb51.net"); Set the URL you want to crawl
curl_setopt ($my _curl,curlopt_returntransfer,1); Set whether to save the result to a string or to the screen, 1 to save the result to a string
$str = curl_exec ($curl); Execute request
Echo $str; Output Crawl Results
Curl_close ($curl); Close URL Request