Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST'

試著忘記壹切 提交于 2019-12-23 07:47:21

问题


I am making a cURL request via Kohana 3.2 but I get the following error when it tries to access CURLOPT_POST constant:

Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST'

From Kohana 3.2 system/classes/kohana/request/client/curl.php

public function _set_curl_request_method(Request $request, array $options)
{
    switch ($request->method()) {
        case Request::POST:
            $options[CURLOPT_POST] = TRUE;
            break;
        case Request::PUT:
            $options[CURLOPT_PUT] = TRUE;
            break;
        default:
            $options[CURLOPT_CUSTOMREQUEST] = $request->method();
            break;
    }
    return $options;
}

My application code:

$request = Request::factory($uri);
$request->query('key', $key);
$request->post($params);
$request->method(Request::POST);

// fails here
$response = $request->execute();

I have tested that curl is active as an extension using:

if (in_array  ('curl', get_loaded_extensions()))
{
    echo '1';
}
else
{
    echo '0';
}

What is the problem here? I am using Windows 7, PHP 5.4.12, and Apache 2.4.


回答1:


First, let's check php-curl has been installed on your server by

aptitude search php-curl

or aptitude search php5.6-curl

if that hasn't been installed yet, let's install it by

sudo apt-get install php5.6-curl



回答2:


I noticed extension=php_curl.dll was commented out in C:\wamp\bin\php\php5.4.12\php.ini but active via C:\wamp\bin\apache\Apache2.4.4\bin\php.ini.

I found that uncommenting the line in C:\wamp\bin\php\php5.4.12\php.ini fixed my issue.



来源:https://stackoverflow.com/questions/22713591/use-of-undefined-constant-curlopt-post-assumed-curlopt-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!