如何在返回false时正确调试PHP curl_setopt_array?

时间:2013-05-12 22:35:48

标签: php curl

代码:

<?php
  $this->curlHandle = curl_init();

  $curl_options = $this->additionalCurlOptions + array(
    CURLOPT_COOKIEJAR => $this->cookieFile,
    CURLOPT_URL => $base_url,
    CURLOPT_FOLLOWLOCATION => TRUE,
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on https.
    CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on https.
    CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
  );
  if (isset($this->httpauth_credentials)) {
    $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials;
  }

  // curl_setopt_array() returns FALSE if any of the specified options
  // cannot be set, and stops processing any further options.
  $result = curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
?>

我需要弄清楚那些卷曲选项出了什么问题。如何调试curl_setopt_array()本身?由于cookiejar是一个(经过测试的)工作文件名,url是正确的,标题函数正在运行,而其他所有选项都是硬编码的,我该怎么做才能深入挖掘?

1 个答案:

答案 0 :(得分:1)

您应该使用复数curl_setopt而不是单数curl_setopt_array进行调试。