file_get_contents无法打开流:连接被拒绝的Godaddy服务器与远程连接服务器 [英] file_get_contents failed to open stream: Connection refused godaddy server with remote connection server

查看:249
本文介绍了file_get_contents无法打开流:连接被拒绝的Godaddy服务器与远程连接服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的URL是远程URL.我可以通过IP地址运行.由于"file_get_contents无法打开流:连接被拒绝"而引发错误.我已经使用了此代码.

Our url is remote url.i can run through Ip address.it thrown error as "file_get_contents failed to open stream: Connection refused".I have use this code.

代码:

$html = file_get_contents('http://xx.xxx.xx.xx:xxxx/apps/index.php');
print_r($html);
var_dump($html); 

此错误是什么?

推荐答案

出于安全原因(php.ini中的allow_url_fopen设置),许多主机会阻止您从远程URL加载文件.最好使用CURL下载文件的内容.

A lot of hosts will prevent you from loading files from remote URLs for security reasons (allow_url_fopen setting in php.ini). It's better to use CURL to download the contents of the file.

<?php
$url = 'http://xx.xxx.xx.xx:xxxx/apps/index.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

参考:通过PHP cURL获取文件内容

HTH:)

这篇关于file_get_contents无法打开流:连接被拒绝的Godaddy服务器与远程连接服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆