Saturday 5 October 2013

file_get_contents vs cURL


In this Post,I will explain difference between file_get_contents and curl.

PHP offers two main options to get a remote file, curl and file_get_contents. There are many difference between the two. Curl is a much faster alternative to file_get_contents.

Using file_get_contents to retrieve http://www.knowledgecornor.com/ took 0.198035001234 seconds. Meanwhile, using curl to retrieve the same file took 0.025691986084 seconds. As you can see, curl is much faster.

file_get_contents - It is a function to get the contents of a file(simply view source items i.e out put html file contents).