下面来看看根据php读取远程服务文件
云EC电商系统(简称云EC)是由佛山市云迈电子商务有限公司自主开发的一套免费、开源的基于PHP+MYSQL电商系统软件。 云EC电商系统 1.2.1 更新日志:2018-08-10 1.修复部分环境下二维码不显示的问题; 2.商品列表增加多属性筛选支持; 3.修复更新优惠券状态时错将已使用的优惠券也更新为过期; 4.修复文章发布远程图片下载失败; 5.修复某些情况下运费计算出错导致
2595
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;
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号