Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Ubuntu中设置php的代理?_Php_Proxy - Fatal编程技术网

如何在Ubuntu中设置php的代理?

如何在Ubuntu中设置php的代理?,php,proxy,Php,Proxy,我在我的大学网络上,该网络使用具有身份验证的代理服务器浏览互联网 我正试图使用html\u get\u contents从网站获取数据,但在终端上运行脚本时出现以下错误: PHP警告:文件获取内容(http://www.google.com/):无法打开流: 第2行的/var/www/api/get_contents.php中无法访问网络 我使用的代码如下所示: <?php $contents = file_get_contents("http://www.google.com/"

我在我的大学网络上,该网络使用具有身份验证的代理服务器浏览互联网

我正试图使用
html\u get\u contents
从网站获取数据,但在终端上运行脚本时出现以下错误:

PHP警告:文件获取内容(http://www.google.com/):无法打开流:
第2行的/var/www/api/get_contents.php中无法访问网络

我使用的代码如下所示:

<?php
    $contents = file_get_contents("http://www.google.com/");
    echo $contents;
?>

似乎我需要为
php
设置代理来获取内容,在哪里设置呢?

使用


在设置选项中:“CURLOPT_PROXYAUTH”、“CURLOPT_PROXYPORT”、“CURLOPT_PROXYTYPE”

嘿,非常感谢@AlexeyKa,我现在想使用
file_get_contents
,从这里的问题中得到了答案: