php curl获取返回值


   curl_setopt($ch, CURLOPT_POST, true);

   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

   这两句放到前面,会获取返回值,放到后面,是curl请求成功或者失败,true或者false

$ch = curl_init();

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0 );
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

$output = curl_exec($ch);
curl_close($ch);
return $output;

标签: php
2017.2.8   /   热度:1463   /   分类: php

发表评论:

©地球仪的BLOG  |  Powered by Emlog