php采用file_get_contents代替使用curl实例
2014-11-07 11:43
916 查看
本文实例讲述了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 替代如下:
$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重写file_get_contents函数实例
- PHP CURL或file_get_contents获取网页标题的代码及两者效率的稳定性问题
- php中file_get_contents与curl性能比较分析
- 深入file_get_contents与curl函数的详解
- 探讨file_get_contents与curl效率及稳定性的分析
- 比file_get_contents稳定的curl_get_contents分享
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- PHP curl 或 file_get_contents 获取需要授权页面的方法
相关文章推荐
- php采用file_get_contents代替使用curl实例
- PHP使用curl替代file_get_contents
- PHP使用curl替代file_get_contents
- PHP使用curl替代file_get_contents
- nginx+fastcgi php 使用file_get_contents、curl、fopen读取localhost本站点.php异常的情况
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- PHP使用curl替代file_get_contents
- php基于curl重写file_get_contents函数实例
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- windows nginx使用file_get_contents、fopen、curl访问php文件造成阻塞的解决办法
- PHP无法使用file_get_contents或者curl_init()函数解决办法
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- PHP使用fopen与file_get_contents读取文件实例分享
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- 使用PHP的curl扩展实现跨域post请求,以及file_get_contents()百度短网址例子
- PHP使用fopen与file_get_contents读取文件实例分享
- PHP中curl_init和file_get_contents配合使用
- PHP使用curl替代file_get_contents
- PHP使用file_get_contents或curl请求https的域名内容为空或Http 505错误的问题排查方法
- php的网络编程(socket、curl、file_get_contents)三种方式。