Why use curl instead of other methods?

Richard picture Richard · Aug 28, 2009 · Viewed 7.6k times · Source

I would like to know why it is better to use curl instead off other methods like $ret=file($url) in php. This is actually used to access an http api for an sms gateway.

Someone dropped a "I would recommend using curl for http connections", but I don't know why.

I just read that it is necessary for Paypal payments, so that does sound interesting.

I did a Google search "why use libcurl", but I haven't found an answer yet.

Could someone explain please?

Answer

JYelton picture JYelton · Aug 28, 2009

I think the FAQ on the curl site says it best:

1.2 What is libcurl?

libcurl is a reliable and portable library which provides you with an easy interface to a range of common Internet protocols.

You can use libcurl for free in your application, be it open source, commercial or closed-source.

libcurl is most probably the most portable, most powerful and most often used C-based multi-platform file transfer library on this planet - be it open source or commercial.

Also, curl facilitates downloading data from multiple sources simultaneously with better efficiency than say file_get_contents() or file().