配置 PHP 以使用代理?

Rob*_*ean 7 php configuration proxy

使用 PHP 5.2.6 并需要将其配置为使用我们的转发代理(需要设置身份验证),以便 PHP 脚本可以正确连接到 Internet。

我看到 4 版本中的 PHP.INI 有一个 pfpro.proxyaddress 选项,但它不再可用 - 那么是什么取代了它?

pQd*_*pQd 4

您可以使用curl 来处理http 检索。

$ch = curl_init("http://whatever.com/something/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, "http://10.14.10.1:3128");
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "user:pass"); 
Run Code Online (Sandbox Code Playgroud)

更多信息在这里