默认不打开文件系统和流配置选项 allow_url_fopen ,而是建议使用一个替代的函数模块 cURL。下面以一个例子说明用 cURL 远程读取的方法:
第一,allow_url_fopen = On 的情况下:
$str = file_get_contents(” http://www.fuwenhao.com “);
if ($str !== false) {
// do something with the content
echo $str;
}
?>
第二,allow_url_fopen = Off 的情况下:
$ch = curl_init(” http://blog.haozi.org/ “);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$str = curl_exec($ch);
if ($str !== false) {
// do something with the content
echo $str;
}
curl_close($ch);
?>
黑龙江省声美网络科技有限公司 技术经验 php调用远程数据的方法 http://www.fuwenhao.com/298.html


常见问题
相关文章
猜你喜欢
- Discuz图片上传函数 2022-06-19
- discuz 积分的名称 2022-06-19
- discuz加载语言包 2022-06-19
- discuz 之block解析 2022-06-19
- Discuz JS 函数addrow解析 2022-06-19
- php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法 2022-06-19
- 关于DISCUZ取时间的问题 2022-06-19
- discuz 调取最新注册会员,用户名,头像,注册日期,注册日期格式化为时间戳的方法 2022-06-19
- html内手机版取消自适应显示PC原版的网页代码。 2022-06-19
- Discuz后台页面函数之表单函数 2022-06-19