详解php中curl返回false的解决办法
首先来看一个封装的curl函数
function request_post($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
$postUrl = $url;
$curlPost = $param;
$curl = curl_init();//初始化curl
curl_setopt($curl, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($curl, CURLOPT_HEADER, 0);//设置header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($curl, CURLOPT_POST, 1);//post提交方式
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);//提交的参数
$data = curl_exec($curl);//运行curl
curl_close($curl);