gpt4 book ai didi

php - 如何获取先前使用 curl_setopt() 设置的选项?

转载 作者:IT王子 更新时间:2023-10-29 00:54:59 27 4
gpt4 key购买 nike

我只是想知道,因为没有 curl_getopt() 函数,如何使用 curl_setopt() 找出为特定选项设置的值?以前?

最佳答案

摘自互联网上的各种答案:

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.

我的建议(和其他建议)是将 cURL 封装到一个类中,您的 $cURL->setOpt() 函数也存储值以供稍后检索。

multirequest PHP 库具有此功能(还有一些!):

$request = new \MultiRequest\Request($url);
$request->setCurlOption(CURLOPT_PROXY, $proxy);
// ...
$curlOptions = $request->getCurlOptions();
list($proxyIp, $proxyPort) = explode(':', $curlOptions[CURLOPT_PROXY]);

关于php - 如何获取先前使用 curl_setopt() 设置的选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5356075/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com