Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

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 (called 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 Internet protocols using one uniform interface, most notably FTP, FTPS, HTTP, HTTPS, and LDAP.

The basic premise to using Curl is that there are four steps: initialize 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 highly 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.

Installing Curl

If you're using Windows, you can enable Curl support by copying the files libeay32.dll and ssleay32.dll into your c:\windows\system32 folder, then enabling the extension in your php.ini file. Look for the line ";extension=php_curl.dll" and take the semicolon off from the beginning.

If you're using Unix, you either have to install Curl support through your package manager, or you need to compile it from source. Compiling Curl support into your PHP takes two steps: installing the Curl development libraries on your machine (do this through your package manager), then recompiling PHP with the —with-curl switch in your configure line. As long as you have ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page