Until recently, to do a web thief program only to find that File_get_content is completely unable to meet the demand. I think that when reading remote content, File_get_content is not as good as curl, except that it's easier to use than curl.
Main differences:
Learn to find that Curl supports a lot of protocols, FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, file, and LDAP, which means it can do a lot of things file_get_content can't. Curl in PHP can achieve remote access and acquisition of content, the implementation of PHP Web version of the FTP upload and download, to achieve the simulation of landing, interface docking (API), data transmission, implementation of analog cookies, download file breakpoints and so on, the function is very powerful.
Understanding curl Some basic use, only to find that it is not difficult, but to remember some of the settings in the parameters, difficult to get a little, but we remember a few commonly used on it.
Turn on Curl:
Because PHP does not support the Curl function by default, so if you want to use curl, you first need to open the function in php.ini, that is, to remove the extension= Php_curl.dll front of the semicolon, and then save and then restart Apache/iis.
Basic syntax:
Copy the Code code as follows:
$my _curl = Curl_init (); Initialize a Curl Object
curl_setopt ($my _curl, Curlopt_url, "http://www.jb51.net"); Set the URL you need to crawl
curl_setopt ($my _curl,curlopt_returntransfer,1); Set whether the result is saved to a string or output to a screen, 1 means that the result is saved to a string
$str = curl_exec ($curl); Execute request
Echo $str; Results of output fetching
Curl_close ($curl); Close URL Request
http://www.bkjia.com/PHPjc/768141.html www.bkjia.com true http://www.bkjia.com/PHPjc/768141.html techarticle until recently, to do a web thief program only to find that File_get_content is completely unable to meet the demand. I think, when reading the remote content, file_get_content except ...