下面来看看根据php读取远程服务文件
function get_content($url)
{
if(!strpos($url, '://')) return 'Invalid URI';
$content = '';
if(ini_get('allow_url_fopen'))
{
$content = file_get_contents($url);
}
elseif(function_exists('curl_init'))
{
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);
$content = curl_exec($handle);
curl_close($handle);
}
elseif(function_exists('fsockopen'))
{
$urlinfo = parse_url($url);
$host = $urlinfo['host'];
$str = explode($host, $url);
$uri = $str[1];
unset($urlinfo, $str);
$content = '';
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if(!$fp)
{
$content = 'Can Not Open Socket...';
}
else
{
$out = "GET $uri HTTP/1.1rn";
$out.= "Host: $host rn";
$out.= "Accept: */*rn";
$out.= "User-Agent: $_SERVER[HTTP_USER_AGENT]rn";
$out.= "Connection: Closernrn";
fputs($fp, $out);
while (!feof($fp))
{
$content .= fgets($fp, 4069);
}
fclose($fp);
}
}
if(empty($content)) $content = 'Can Not Open Url, Please Check You Server ...
For More Information, Please Visit www.111cn.net;
return $content;
}

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

记事本++7.3.1
好用且免费的代码编辑器

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

SublimeText3 Linux新版
SublimeText3 Linux最新版

SublimeText3 英文版
推荐:为Win版本,支持代码提示!