Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
PHP Curl可以';无法从任何url获取数据_Php_Linux_Curl - Fatal编程技术网

PHP Curl可以';无法从任何url获取数据

PHP Curl可以';无法从任何url获取数据,php,linux,curl,Php,Linux,Curl,我正试图用这段代码获取一些数据 function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); return $

我正试图用这段代码获取一些数据

function file_get_contents_curl($url) {
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_URL, $url);
 $data = curl_exec($ch);
 curl_close($ch);
 return $data;
 }
  $file= file_get_contents_curl('www.website.com/page');
我得到了7号错误

CURLE_COULDNT_CONNECT (7)
Failed to connect() to host or proxy.
我也尝试过www.google.com,但我也有同样的错误

我想我必须在服务器(linux)上更改一些东西,但我不知道是什么


谢谢。

您的问题以前已经得到了回答。您可以检查此问题:


如果你抓不到谷歌,你必须检查你的防火墙。

你用前面的http://试过了吗?你用命令行上的“curl google.com”试过了吗?我用前面的http://试过了。它在本地主机上工作。我不知道如何在我的托管服务器上的命令行上尝试“curl google.com”。你真的可以访问服务器上的命令行吗?不,我只能上载文件。我有权访问phpmyadmin,我不知道我可以从那里修复一些东西。我已经在回答中检查了该url,但我不知道如何在我的托管服务器上禁用selinux。我没有提到我的代码在localhost上工作。