[英]file_get_contents/curl PHP Function Not Working For IP Address
My server contain a file at http://XX.XX.XX.XX:7550/check.txt
and in which only Online
is written. 我的服务器包含一个位于
http://XX.XX.XX.XX:7550/check.txt
的文件,并且其中仅写入了Online
。 Now I am on my shared hosting and I want to get Online
in my shared hosting php file for that I am using the below code in my shared hosting php file. 现在,我在共享主机上,我想在共享主机php文件中获得“
Online
,因为我在共享主机php文件中使用了以下代码。
<?php
var_export(ini_get('allow_url_fopen'));
$uri = 'http://XX.XX.XX.XX:7550/check.txt';
$result = file_get_contents($uri);
echo $result;
?>
But I am only getting '1'
instead of '1' Online
. 但是我在
'1' Online
只得到'1'
而不是'1' Online
。 So can you answer my why not working when I enter my server IP? 那么您能回答我输入服务器IP时为什么不起作用的原因吗?
Note: And when I am adding http://www.google.com
instead of http://XX.XX.XX.XX:7550/check.txt
then I am getting whole Google page. 注意:当我添加
http://www.google.com
而不是http://XX.XX.XX.XX:7550/check.txt
我将获得整个Google页面。
Important Note: I am able to open http://XX.XX.XX.XX:7550/check.txt
in my web-browser directly via proxy means no firewall blocking is in my server ( Ubuntu Server 14.04 LTS ). 重要说明:我可以直接通过代理在Web浏览器中打开
http://XX.XX.XX.XX:7550/check.txt
,这意味着服务器上没有防火墙阻止( Ubuntu Server 14.04 LTS )。
I also tried CURL
and that's also not working with http://XX.XX.XX.XX:7550/check.txt
but working with http://www.google.com
. 我还尝试了
CURL
,但它也不能与http://XX.XX.XX.XX:7550/check.txt
一起使用,但可以与http://www.google.com
一起使用。
<?php
function curl_load($url){
curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$url = "http://XX.XX.XX.XX:7550/check.txt";
echo curl_load($url);
?>
尝试使用cUrl而不是file_get_contents。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.