I'm just wondering as there is no curl_getopt() function, how it is possible to find out which value has been set for a specific option with curl_setopt()
previously?
The curl_setopt() function will set options for a CURL session identified by the ch parameter. The option parameter is the option you want to set, and the value is the value of the option given by the option.
When CURLOPT_VERBOSE is set, output is written to STDERR or the file specified using CURLOPT_STDERR . The output is very informative. You can also use tcpdump or wireshark to watch the network traffic.
CURLOPT_POSTFIELDS. The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ';type=mimetype'.
Pulled from various answers around the internets:
Question: Is there a way to get the current curl option settings? Like a curl_getopt() or curl_showopts()?
Answer: Yes and no. There is curl_getinfo() which will show you some info about the last connection, but I suspect it's not what you're looking for. It's a weakness in curl, IMHO.
My suggestion (and others) is to encapsulate cURL into a class where your $cURL->setOpt()
function also stores the value for retrieval later.
The multirequest PHP library has this functionality (and then some!):
$request = new \MultiRequest\Request($url); $request->setCurlOption(CURLOPT_PROXY, $proxy); // ... $curlOptions = $request->getCurlOptions(); list($proxyIp, $proxyPort) = explode(':', $curlOptions[CURLOPT_PROXY]);
Possibly curl_getinfo()
may satisfy some of your needs. If not, you can write a wrapper of curl_setopt()
which saves all options to an array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With