Curl

The cURL extension to PHP is designed to allow you to use a variety of web resources from within your PHP script. The name cURL (we will be calling it Curl from now on for ease of reading) stands either for "Client for URLs" or "Client URL Request Library", but the function is the same - it lets you use several web protocols using one uniform interface, most notably FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, and LDAP.

The basic premise to using Curl is that there are four steps: initialise Curl, set your options, execute your query, and close Curl. Steps 1, 3, and 4 are easy, with the majority of the work taking place in step 2. Curl is very, very configurable, and there are dozens of options you can set to make it do all sorts of weird and wonderful things. While this is undoubtedly a great advantage, it does make the learning curve a little high. This book is not solely about Curl, so we shall not be covering it in its entirety, however I have picked a selection of uses for Curl that should give you enough of a head start to be able to learn the rest yourself.

 

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Installing Curl >>

Previous chapter: Other helpful FTP functions

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.