dongpan9760 2014-08-26 04:49
浏览 1881
已采纳

如何将cURL结果传递给变量

Hi all I need help regarding cURL, I'm new to using cURL in PHP so I want to ask this.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $get_url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$variable = curl_exec($curl);

$variable's value is boolean while cURL echoes a string during execution. Is there anyway I could get that echoed string pass to a variable?

Thanks in advance

  • 写回答

2条回答 默认 最新

  • dongsaolian8786 2014-08-26 04:53
    关注

    Set the option curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); to return the result as a string, in your case the string will be stored in $variable. Then, pass $variable to whatever function you desire.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥15 MATLAB数据处理插值
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的
  • ¥15 硬件IIC从模式的数据发送,中断数据的接收,不能用HAL库(按照时序图)