设为首页
收藏本站
用户名
Email
自动登录
找回密码
密码
登录
立即注册
只需一步,快速开始
快捷导航
登录
注册
论坛首页
BBS
建站模版
微站设计
虚拟主机
企业邮箱
博客日志
Blog
搜索
搜索
搜索
热搜
长春
优惠
活动
做网站
本版
帖子
用户
本版
帖子
用户
请
登录
后使用快捷导航
没有帐号?
立即注册
道具
勋章
任务
留言板
设置
我的收藏
退出
时时商务社区
»
论坛首页
›
建站资源
›
建站技术
›
php采用file_get_contents代替使用curl实例
返回列表
查看:
837
|
回复:
0
php采用file_get_contents代替使用curl实例
[复制链接]
yj1281
当前离线
积分
7391
2487
主题
2487
帖子
7391
积分
论坛元老
论坛元老, 积分 7391, 距离下一级还需 9992608 积分
论坛元老, 积分 7391, 距离下一级还需 9992608 积分
积分
7391
发消息
电梯直达
楼主
发表于 2018-2-14 05:53:11
|
只看该作者
|
倒序浏览
|
阅读模式
本文实例讲述了php采用file_get_contents代替使用curl的方法,分享给大家供大家参考。具体实现方法如下:
file_get_contents代替使用curl其实不多见了,但有时你碰到服务器不支持curl时我们可以使用file_get_contents代替使用curl,下面看个例子。
当用尽一切办法发现 服务器真的无法使用curl时。或者curl不支持https时。curl https 出现502时。你又不想重装网站环境的时候,你就改用file_get_contents 代替吧。
curl 经常使用的 curl get curl post
curl get 替代 直接用file_get_contents($url) 就可以了
curl post 替代如下:
[U]复制代码[/U] 代码如下: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中使用Curl、socket、file_get_contents三种方法POST提交数据
比file_get_contents稳定的curl_get_contents分享
探讨file_get_contents与curl效率及稳定性的分析
深入file_get_contents与curl函数的详解
php中file_get_contents与curl性能比较分析
PHP CURL或file_get_contents获取网页标题的代码及两者效率的稳定性问题
php基于curl重写file_get_contents函数实例
PHP curl 或 file_get_contents 获取需要授权页面的方法
分享到:
QQ好友和群
QQ空间
腾讯微博
腾讯朋友
收藏
0
回复
使用道具
举报
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
用户反馈
客户端