如何在 PHP 中设置 HTTP 代理设置? [英] How to setup HTTP proxy settings in PHP?

查看:115
本文介绍了如何在 PHP 中设置 HTTP 代理设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 PHP 编写一个我已经用 Java 编写的程序.我使用以下语句在 Java 中设置代理

I am trying to write a program in PHP which I had already written in Java. I had used the following statements to setup proxy in Java

System.setProperty("http.proxyHost",proxyhost);
System.setProperty("http.proxyPort",proxyport);

如何对 PHP 执行相同的操作?

How do I do the same for PHP?

推荐答案

我认为你可能需要使用 cURL 扩展来进行传输并将相关的代理选项传递给 cURL.

I think you may need to use the cURL extension to carry out the transfer and pass the relevant proxy options to cURL.

cURL 扩展

curl_setopt 函数将选项传递给 cURL 会话

curl_setopt function to pass options to a cURL session

您需要的代理选项是:CURL_PROXY 和 CURL_PROXYPORT.

The proxy options you need are: CURL_PROXY and CURL_PROXYPORT.

这篇关于如何在 PHP 中设置 HTTP 代理设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆