I am Hack Sparrow
Captain of the Internets.

PHP CURLOPT_GET Does not Exist!

CURLOPT_GET is not a PHP constant

Sooner or later someone's going run into this notice error: Use of undefined constant CURLOPT_GET - assumed 'CURLOPT_GET'. Probably you downloaded a PHP class or a function written by someone else from the Web. Right?

Well, no matter how you ended up with that notice, let's try to analyze the problem and the solution.

Take a look at the example code:

curl_setopt($ch, CURLOPT_GET, true);

We can safely assume that it's trying to set the HTTP request type to GET. I have no idea if PHP once used to support it or not but CURLOPT_GET is indeed a non-existent PHP constant. Confirm it yourself here. So the probability is that the constant is a result of PHP code from the stone age or a customized PHP environment or from a coder who assumed there would be CURLOPT_GET, just as there is CURLOPT_POST, but did not care to debug the code properly. None of which we are interested in as long as we have a solution to the notice error.

The solution is you just comment out that code. Because CURL request by default is GET, you don't have to set any options to make a GET CURL request.

The nearest CURL option which looks like is CURLOPT_GET is CURLOPT_HTTPGET, which you might not need to use at all in the first place. CURLOPT_HTTPGET is used to reset the HTTP request method if you had set it to anything but GET.

In my opinion this mysterious CURL option was created by a PHP developer who assumed the existence of CURLOPT_GET based on CURLOPT_POST - and had the error reporting level set to hide notice errors. Always keep you error reporting level to E_ALL | E_STRICT - especially in your development environment.


  1. PHP CURL Options
  2. Turning on PHP Error Reporting
  3. PHP Client URL Library

6 Responses to “PHP CURLOPT_GET Does not Exist!”

  1. Salarmehr says:

    Thanks a lot, very helpful post

  2. Jeff Kee says:

    I’m glad I did a Google search before I put the CURLOPT_GET in my code. Thank you.

  3. Captain says:

    No problemo, Jeff. All the best!

  4. Neil says:

    Thanks for post , I cam accross this example after working through a book that gives an example of using CURLOPT_GET.

    RESTful PHP Web Services
    ISBN 978-1-847195-52-4

    Will have to tell them 🙂

  5. Matt says:

    Thanks Captain!

  6. Erick says:


Make a Comment