如何获取先前用curl_setopt()设置的选项? [英] How to get an option previously set with curl_setopt()?
问题描述
我只是想知道,因为没有curl_getopt()函数,如何可以找出哪个值已经设置了一个特定的选项与 curl_setopt()
?
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?
推荐答案
从互联网周围的各种答案中提取:
Pulled from various answers around the internets:
/ strong>有一种方法来获取
当前curl选项设置?像
curl_getopt()或curl_showopts()?
Question: Is there a way to get the current curl option settings? Like a curl_getopt() or curl_showopts()?
回答:有
curl_getinfo(),它会显示一些
关于最后一个连接的信息,但是I
怀疑它不是你正在查找的
。
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.
我的建议(和其他人)是将cURL封装到一个类中,其中$ cURL-> setOpt()函数还存储稍后检索的值。
My suggestion (and others) is to encapsulate cURL into a class where your $cURL->setOpt() function also stores the value for retrieval later.
multirequest PHP库具有此功能(然后一些!):
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]);
这篇关于如何获取先前用curl_setopt()设置的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!