如何获取curl_php()中使用的http方法

时间:2019-07-17 06:33:39

标签: php curl libcurl php-curl

如何获取curl_php连接中使用的HTTP方法(如GET,POST,DELETE)? curl_getinfo中不可用。 连接的代码是

$options = array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER         => false,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_MAXREDIRS      => 10,
            CURLOPT_ENCODING       => "",
            CURLOPT_AUTOREFERER    => true,
            CURLOPT_CONNECTTIMEOUT => 120,
            CURLOPT_TIMEOUT        => 120,
    );
    $response = curl_init($url);
    curl_setopt_array($response, $options);
    $content  = curl_exec($response);
    $options_debug = curl_getinfo($response);
    curl_close($response);

1 个答案:

答案 0 :(得分:0)

默认情况下,除非另行指定,否则cURL方法始终为GET。另外,如果您使用-d或--data调用cURL,则请求将为POST。

POST request override default GET when using -d parameter.

此处有更多信息:cURL info

BR