curl and file_get_content

Difference between curl and file_get_content
No. file_get_content curl
1 It is a function to get the contents of a file. It is a library.curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading HTTP form based upload, proxies, cookies.
2 file_get_contents() for a remote file, it is very slow, and does not handle redirects, caching, cookies. Curl is a much faster alternative to file_get_contents.
3 It is a function to get the contents of a file (simply view source items i.e out put html file contents). It is a library to do more operations, for example get the contents like file_get_contents, sending and receiving data from one site to another site and it also supports different types of protocols like http, https, ftp, gopher, telnet, dict, file, and ldap. curl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading HTTP form based upload, proxies, cookies.
4 <?php
$output = file_get_contents(‘http://www.example.com/’);
echo $output;
?>
<?php
$url=’http://www.example.com/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
?>

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>