加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php采用file_get_contents代替使用curl实例

发布时间:2020-12-13 02:08:34 所属栏目:PHP教程 来源:网络整理
导读:《PHP实战:php采用file_get_contents代替使用curl实例》要点: 本文介绍了PHP实战:php采用file_get_contents代替使用curl实例,希望对您有用。如果有疑问,可以联系我们。 本篇章节讲解php采用file_get_contents代替使用curl的办法,供大家参考研究

《PHP实战:php采用file_get_contents代替使用curl实例》要点:
本文介绍了PHP实战:php采用file_get_contents代替使用curl实例,希望对您有用。如果有疑问,可以联系我们。

本篇章节讲解php采用file_get_contents代替使用curl的办法,分享给大家供大家参考.具体实现办法如下:PHP实战

file_get_contents代替使用curl其实不多见了,但有时你碰到服务器不支持curl时我们可以使用file_get_contents代替使用curl,下面看个例子.PHP实战

当用尽一切方法发现 服务器真的无法使用curl时.或者curl不支持https时.curl https 出现502时.你又不想重装网站环境的时候,你就改用file_get_contents 代替吧.
curl 经常使用的 curl get curl post
curl get 替代 直接用file_get_contents($url) 就可以了
curl post 替代如下:PHP实战

代码如下:
function Post($url,$post = null) {??????
??????? $content = http_build_query($post);
??????? $content_length = strlen($content);
??????? $options = array(
??????????? 'http' => array(
??????????????? 'method' => 'POST',
??????????????? 'header' =>"Content-type: application/x-www-form-urlencoded",
??????????????? 'content' => $post
??????????? )
??????? );
??????? return file_get_contents($url,false,stream_context_create($options));
}

希望本文所述对大家的php程序设计有所赞助.PHP实战

《PHP实战:php采用file_get_contents代替使用curl实例》是否对您有启发,欢迎查看更多与《PHP实战:php采用file_get_contents代替使用curl实例》相关教程,学精学透。编程之家 52php.cn为您提供精彩教程。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读