views:

29

answers:

1

I was refactoring my cURL class today and thought about looking at default values of cURL FLAGS.
Could anyone tell me where I might find or how could I output them?

PS: If it's possible at all.

+2  A: 

This will display the "CURL*" constant names and their values:

foreach (get_defined_constants() as $name => $val) {
    if (strpos($name, 'CURL') === 0) {
        echo $name . ' => ' . $val . "\n";
    }
}

For just the curl option values, change 'CURL' to 'CURLOPT_', of course.

(If you're thinking of using the integer values instead of the constant names in your script, you shouldn't.)

GZipp
+1 for the code. also, for reference to curl option flags check this - http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
bhu1st
@bhu1st - +1 for your comment. It should be kept in mind, though, that not all the options described there are in the PHP implementation.
GZipp
Ok. Now that's a bit strange. How is it possible `CURLOPT_HEADER => 42`? Shouldn't the value be 1 or 0 (true/false)?
Eugene
@Eugene - The CURLOPT_* values are used under the hood in bitwise operations, not as true/false values. True and false are used only in the parameters to the curl_setopt() and curl_setopt_array() "convenience" functions.
GZipp
@Eugene - I realize now that I haven't really answered your question. My code doesn't tell you whether a given option is on or off, only what the value of the constant is. Back to the proverbial drawing board.
GZipp