The abridged list of Curl options

There are a large number of options available for curl_setopt() - far too many to cover here. However, of the full list, about half or so are used regularly and therefore deserve printing here. We will be looking at some of these in more depth shortly, but generally the whole list here is useful for the basic set of Curl operations:

If the 2nd parameter is...

3rd parameter should be...


String containing the contents of the cookie data to be set in the HTTP header.


String containing the name of the file containing cookie data to be sent.


1 if you want Curl to convert Unix new lines to CR/LF new lines


1 if you want Curl to fail silently if the HTTP code returned is equal to or larger than 300.


String containing the filename where the output of your transfer should be placed. Default is straight to output (STDOUT).


1 if you want Curl to follow all "Location: " header that the server sends as part of the HTTP header. You can limit the number of location headers to follow using CURLOPT_MAXREDIRS.


1 to have Curl append to the remote file instead of overwriting it.


1 to list just the names of an FTP directory as opposed to more detailed information.


1 if you want the header to be included in the output. Usually for HTTP only.


An array of HTTP header fields to be set.


String containing the filename where the input of your transfer comes from.


The size of the file being uploaded to a remote site.


The number of "Location:" headers Curl should follow before erroring out. This option is only appropriate if CURLOPT_FOLLOWLOCATION is used also.


1 to tell Curl not to include the body part in the output. For HTTP(S) servers, this is equivalent to a HEAD request - only the headers will be returned.


1 if you want Curl to do a regular HTTP POST.


A string containing the data to post in the HTTP "POST" operation.


A string containing the "referer" header to be used in an HTTP request. This is only necessary if the remote server relies on this value.


A number equal to the offset, in bytes, that you want your transfer to start from.


1 if you want Curl to return the transfer data instead of printing it out directly.


A string containing the filename to write errors to instead of normal output.


A number equal to the maximum time in seconds that Curl functions can take.


1 if you want PHP to prepare for a file upload.


String containing the URL you want Curl to fetch.


A string formatted in the username:password manner, for Curl to give to the remote server if requested.


A string containing the "user-agent" header to be used in a HTTP request.


1 if you want Curl to give detailed reports about everything that is happening.


containing the filename to write the header part of the output into.

As you can see there are quite a few headers, and those are only the most popular - there is a large selection more available online at


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: Debugging Curl >>

Previous chapter: Your first Curl scripts

Jump to:


Home: Table of Contents

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