Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.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在windows上工作,但在Linux上获得404_Php - Fatal编程技术网

PHP CURL在windows上工作,但在Linux上获得404

PHP CURL在windows上工作,但在Linux上获得404,php,Php,我在我的windows机器上使用了这段代码,页面加载的代码是200,但如果我把这段代码放在我的主机linux上,那么我会得到404错误,这是什么原因呢?如果你只需要页面的内容,也许使用文件获取内容更容易些 有时curl没有启用,或者它是curl模块中的一个bug $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.rlsnet.ru/tn_alf_letter_1.htm'); curl_setopt($ch, CURLOP

我在我的windows机器上使用了这段代码,页面加载的代码是200,但如果我把这段代码放在我的主机linux上,那么我会得到404错误,这是什么原因呢?

如果你只需要页面的内容,也许使用文件获取内容更容易些

有时curl没有启用,或者它是curl模块中的一个bug

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.rlsnet.ru/tn_alf_letter_1.htm');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec($ch);
echo $data;
exit;

er。。为了安全起见,cURL是否安装在linux中?是的,如果没有安装,它甚至不会被执行,执行是可以的,但答案是404为什么你用同样的问题滥发SO?首先,然后再问这个问题。我认为您的主机无法授予执行cUrl的权限,因为PHP safemod等。也许您的主机/网络/dns配置有问题。安装lynx并使用它尝试url。但是不要多次发布同一个问题。同样的情况也发生在文件内容上。我得到404错误。那么端口可能被阻止用于传出连接。是招待员吗?或者你自己的服务器?看看这个:不,看看这个url是不是-没问题,但是这个url-给我一个404错误,只有在linux中,在windows中是可以的
<?php
$res = file_get_contents('http://www.rlsnet.ru/tn_alf_letter_1.htm');
echo $res;