php卷曲问题
我试图用curl获取远程文件的信息。问题是其他Web服务器在端口81上。
I am trying to get information of remote file with curl. Problem is that other web-server is on port 81.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt ($ch, CURLOPT_PORT , 81);
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185/server_status2.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);
?>
并且你可以看到它不工作。
And as you can see it doesnt work.
如果在URI中指定端口号,会发生什么?
What happens if you specify the port number in the URI ?
我的意思是先删除 CURLOPT_PORT
行,然后修改 CURLOPT_URL
一行以添加端口号:
What I mean is first remove the CURLOPT_PORT
line, and, then, modify the CURLOPT_URL
one to add the port number :
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185:81/server_status2.php');
在注释后编辑:我只是尝试这部分代码:
Edit after the comment : I just tryied this portion of code :
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
//curl_setopt ($ch, CURLOPT_PORT , 81);
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185:81/server_status2.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);
我得到这个输出:
Online Peak: 59
Online: 17
Distributive server: Online
Agent server: Online
所以,代码似乎没问题。
So, the code seems to be OK.
你确定没有防火墙或任何东西,您的网络,阻止您对该服务器的端口81执行HTTP请求?
在浏览器中键入该URI时是否有效?
Are you sure there is not a firewall or anything or your network, that prevents you from doing HTTP requests on port 81 to that server ?
Does it work when you type that URI in your browser ?