php7使用curl
/**
* @param string $url
* @return mixed
*/
public function doGet($url)
{
//初始化
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url);
// 执行后不直接打印出来
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
// 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// 不从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //执行并获取HTML文档内容
$output = curl_exec($ch); //释放curl句柄
curl_close($ch); return $output;
} /**
* @param string $url
* @param array $post_data
* @param array | boolean $header
* @return mixed
*/
public function doPost($url,$post_data,$header)
{
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);
// 执行后不直接打印出来
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 设置请求方式为post
curl_setopt($ch, CURLOPT_POST, true);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// 请求头,可以传数组
curl_setopt($ch, CURLOPT_HEADER, $header);
// 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// 不从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $output = curl_exec($ch);
curl_close($ch); return $output;
}
php7使用curl的更多相关文章
- CentOS7 php7 安装 curl 扩展
直接从php源码包中,使用root权限安装. 找到原先安装PHP的源码包文件(如果已经删掉需要重新下载原来版本的源码包并解压) 我的php源码包在root家目录下. cd /php-7.1.4/ext ...
- 【转载】兼容php5,php7的cURL文件上传示例
转载来自: http://www.huanlinna.com/2016/06/25/coding/php5-php7-upload-demo-via-curl.html https://segment ...
- 关于PHP7的CURL上传文件
CULR 部分 $url = 'http://localhost/test/curlUploadFile/upload.php'; //处理上传的php文件,根据情况修改 $path='ftp.txt ...
- 在 Ubuntu/Debian 下安装 PHP7.3 教程
介绍 最近的 PHP 7.3.0 已经在 2018 年12月6日 发布 GA,大家已经可以开始第一时间体验新版本了,这里先放出 PHP7.3 安装的教程以便大家升级. 适用系统: Ubuntu 18. ...
- php7的扩展库安装方法
转:https://www.cnblogs.com/to-be-rich/p/8001175.html 今天的知识点:1.php的再次编译不会对现有的php业务有影响,只有正式kill -USR2 p ...
- 使用PPA在Ubuntu上安装php5.4~5.6,7
使用PPA在Ubuntu上安装php5.4~5.6,7 sudo apt-get install software-properties-common sudo add-apt-repository ...
- ppa安装php版本
如果你想安装PHP的特定版本,那么这篇文章可以帮助你.这篇文章将帮助您安装PHP 5.4和PHP 5.5 PHP 5.6,通过使用PPA在Ubuntu 15.10 LTS,14.04或12.04 LT ...
- ubuntu下程序员常用命令大全
一.ubuntu下用命令查询系统版本 1.在终端中执行下列指令: cat /etc/issue 该命令可查看当前正在运行的ubuntu的版本号. 效果如图: 2.使用 lsb_release 命令也可 ...
- 基于Ubuntu的LNMP环境搭建
装备的工具 Ubuntu16.04 , Xshell 使用Xshell链接到Ubuntu 使用xshell链接Ubuntu不是必须的,只是为了操作的方便,同时默认是你的Ubuntu已经安装好了 在Ub ...
随机推荐
- 【转载】Linux升级NTPD服务器-编译安装ntp-4.2.8p12与配置
[转载]Linux升级NTPD服务器-编译安装ntp-4.2.8p12与配置 1. 系统与软件版本 1.1 系统版本 rhel6.4(Red Hat Enterprise Linux Server r ...
- mysql类型与java类型对应异常场景
MySQL的bigint unsigned类型,对应java的BigInteger类型,在基于mybatis框架时,如果我将bigint unsigned类型的字段的返回放在一个map的返回类型中时. ...
- hdu 6057 Kanade's convolution(子集卷积)
题解: 然后就是接下来如何fwt 也就是如何处理bit(x) - bit(y) = bit(k)这个条件. 其实就是子集卷积. 把bit(x)和bit(y)划分成两个集合,然后就是子集卷积的形式. 这 ...
- [洛谷P2839][国家集训队]middle
题目大意:给你一个长度为$n$的序列$s$.$Q$个询问,问在$s$中的左端点在$[a,b]$之间,右端点在$[c,d]$之间的子段中,最大的中位数. 强制在线. 题解:区间中位数?二分答案,如果询问 ...
- [Leetcode] Multiply strings 字符串对应数字相乘
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...
- vector 基础2
size :返回有效元素个数 max_size :返回 vector 支持的最大元素个数 resize :改变有效元素的个数 capacity :返回当前可使用的最大元素内存块数(即存储容量) ...
- css中文本超出部分省略号代替
p{ width: 100px; //设置p标签宽度 white-space: nowrap; //文本超出P标签宽度不换行,而是溢出 overflow: hidden; //文本超出P标签,超出部分 ...
- [object-c 2.0 程序设计]object-c file handle (二)
// // main.m // cmdTry // // Created by Calos Chen on 2017/8/21. // Copyright © 2017年 Calos Chen. Al ...
- 【洛谷 P2480】 [SDOI2010]古代猪文(中国剩余定理,Lucas定理)
题目链接 这题出的有点nb,PKU: Pig Kingdom University , NOIP: National Olympics in Informatic of Pigs... 题意:求\(G ...
- JS组件入门
用React感觉component老好用了. 那如何用原生JS来模拟实现React中的component方法呢:http://huziketang.com/blog/posts/detail?post ...